I often find myself stringing together a series of shell commands, ultimately with the goal to replace the contents of a file. However, when using >
it opens the original file for writing, so you lose all the contents.
For lack of a better term, is there a "lazy evaluation" version of >
that will wait until all the previous commands have been executed before before opening the file for writing?
Currently I'm using:
somecommand file.txt | ... | ... > tmp.txt && rm file.txt && mv tmp.txt file.txt
Which is quite ugly.