> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/unix/sort-file-inline.md).

# sort file inline

We can sort file by using `sort` command for example:

```bash
$ sort a.txt

# or

$ cat a.txt | sort
```

But this will only output to stdout. Some time you want the file to be sorted. Instead you can do

```bash
$ sort a.txt -o a.txt
```

note that this DOEST work and it will TRUNCATE the file

```bash
$ sort a.txt > a.txt
```
