Sponge of pipes

cmd1 $file | sponge $file

With sponge at the end you can manipulate the file before and write to itself. But be careful if the commands before sponge exit for some reason the file might be lost and you produce a empty file.

Published: November 24 2014

blog comments powered by Disqus