Read stdin and write to a file atomically without buffering
Soak up standard input and write to a file
sponge
$ sed 's/old/new/g' file.txt | sponge file.txt
$ grep 'pattern' data.txt | sponge data.txt
$ sort unsorted.txt | sponge unsorted.txt