Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between sponge and tee

Tags:

linux

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?

like image 213
crsuarezf Avatar asked Nov 10 '15 20:11

crsuarezf


1 Answers

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.

like image 127
alsjflalasjf.dev Avatar answered Oct 13 '22 23:10

alsjflalasjf.dev