Wait, is sponge just another way to redirect to a file? What's the benefit of:
$ echo hi |sponge y
over: $ echo hi > y
? $ echo hi |sponge y
over: $ echo hi > y
?> Unlike a shell redirect, sponge soaks up all its input before opening the output file. This allows constructing pipelines that read from and write to the same file.
$ echo 'foo' > foo
$ echo 'bar' > bar
$ cat foo bar > foo
cat: foo: input file is output file
$ cat foo
bar
vs $ echo 'foo' > foo
$ echo 'bar' > bar
$ cat foo bar | sponge foo
$ cat foo
foo
bar