> It also sucks. avoiding a temporary file is the whole point to sponge.
> otherwise:
>
> cat file | grep file > file_temp; mv file_temp file;
Actually, it would be
tmp = $(mktemp)
grep 'foo' file > $tmp
cat $tmp > file
Not only that, but tmpfile(3) is safer with respect to race
conditions. You'll notice that even moreutils sponge always opens a
tempfile[1]. In fact, it's really stupid: first it fills up all your
remaining memory then, it writes all of that to a tempfile, which if
in a tmpfs-mounted /tmp will fail miserably.
[1]:
https://gitorious.org/moreutils/moreutils/blobs/master/sponge.c:283
Received on Tue Jul 02 2013 - 21:39:06 CEST