On Fri, Apr 13, 2012 at 19:50, Strake wrote: >> There is also sponge from http://kitenet.net/~joey/code/moreutils/ > > which would also corrupt file on failure, by what little documentation > I can read through the markup.
You are right. I thought that since it only opens the output file after stdin is fully consumed, it would not touch the file on failure. The test below reveals that sponge leaves the file alone if the process is interrupted before end of stdin, but not if a program before it in the pipe returns non-zero. I guess I should test programs before suggesting them to others. -Truls $ echo TEST > tst $ (sed s/ES/se tst; sleep 10) | sponge tst sed: -e expression #1, char 7: unterminated `s' command ^C $ cat tst TEST $ sed s/ES/se tst | sponge tst sed: -e expression #1, char 7: unterminated `s' command $ wc tst 0 0 0 tst $