How can I redirect input and output to a same file in general? I mean specifically there is -o
for the sort
command and there might be other such options for various command. But how can I generally redirect input and output to same file without clobbering the file?
For example: sort a.txt > a.txt
destroys the a.txt
file contents, but I want to store answer in the same file. I know I can use mv
and rm
after using a temporary file, but is it possible to do it directly?