3 ms·
sponge (1) is a simple way to do this, but not available on all systems. See http://joey.kitenet.net/code/moreutils/ http://joey.kitenet.net/code/moreutils/
by jluxenberg 17y ago
sponge (1) is a simple way to do this, but not available on all systems. See http://joey.kitenet.net/code/moreutils/ http://joey.kitenet.net/code/moreutils/
- LlamaZorz 16y agoThanks for this.
- TorKlingberg 17y agoThis is the most convenient solution. "sponge reads standard input and writes it out to the specified file. Unlike a shell redirect, sponge soaks up all its input before opening the output file. This allows for constructing pipelines that read from and write to the same file." I remember writing a script that did the same thing (in Perl or maybe it was Bash).