sort file inline
We can sort file by using sort command for example:
1
$ sort a.txt
2
​
3
# or
4
​
5
$ cat a.txt | sort
Copied!
But this will only output to stdout. Some time you want the file to be sorted. Instead you can do
1
$ sort a.txt -o a.txt
Copied!
note that this DOEST work and it will TRUNCATE the file
1
$ sort a.txt > a.txt
Copied!
Last modified 1mo ago
Copy link