How do I execute any command editing its file (argument) "in place" using bash?
I have a documents temp.txt, that I intend to arrange with the
sort command in bash.
I desire the arranged outcomes to change the initial documents.
This does not benefit instance (I get a vacant documents) :
sortx temp.txt > temp.txt
Can this be carried out in one line without considering replicating to short-lived files?
-o alternative is really trendy for
sort. I made use of
sort in my inquiry as an instance. I face the very same trouble with various other commands:
uniq temp.txt > temp.txt.
Is there a far better basic remedy?
If you demand making use of the
sort program, you need to make use of a intermediate documents - - I do not assume
sort has an alternative for sorting in memory. Any kind of various other method with stdin/stdout will certainly fall short unless you can assure that the barrier dimension for type is stdin allows sufficient to fit the whole documents.
Edit: embarassment on me.
sort temp.txt -o temp.txt functions superb.
Many have actually stated the - o alternative. Below is the male web page component.
From the male page:
-o output-file Write output to output-file instead of to the standard output. If output-file is one of the input files, sort copies it to a temporary file before sorting and writing the output to output- file.