When we use sort file
command,
the file shows its contents in a sorted way what if I don\'t want to get any-kind of output but a sorted file?
To sort file in place, try:
echo "$(sort your_file)" > your_file
As explained in other answers, you cannot directly redirect the output back to the input file. But you can evaluate the sort
command first and then redirect it back to the original file. In this way you can implement in-place sort.
Similarly, you can also apply this trick to other command like paste
to implement row-wise appending.