linuxtee

Differences between sponge and tee


While doing some work, I found this "sponge" command that does the same as "tee", but could not find when it is better to use one or the other.

Can someone explain?


Solution

  • No one of them soak up stderr; only stdout. 'tee' writes stdin on stdout and files. 'sponge' writes stdin only on a file; without errors, no output. (i.e: Unlike 'tee', 'sponge' doesn't write on stdout). Besides,

    "sponge soaks up all its input before opening the output file"

    (from its manual)

    This difference between them is extremely relevant: 'tee' "reads a byte", and "writes that byte"; 'sponge' waits to receive all the input, and then, writes it.