Sending a stream to multiple outputs

I was looking for a way to compare compression ratios with different algorithms, and didn’t want to have to run them in serial. So I started digging and found a nice bash syntax that allows you to do just that. And just for fun, it calculates the sha checksum as well.

curl -s | tee >(gzip -9 > file.txt.gz) >(bzip2 -9 > file.txt.bz2 ) | shasum

Leave a Comment