How do I maintain a readable output from my program while also putting that same output into a compressed file, gzip or otherwise, so I can parse it later?
I run a command that generates a lot of samey lines of clear text that should be easy to compress, but I also want to monitor the output of that command. I know I can use tee
to print and then put stdin into a file. But the files are massive (250MB+). I also know that I can use gzip
to compress stdin into a file, but then I won't see any output on the screen and gzip's --stdout
flag just dumps the compressed data to stdout, which is not what I want.
An example would be
python -c 'for i in range(0, 100): print("A" * 120)' | gzip --best > A.log.gz
but I also want to see the A
s printed to the console.
seq 1 100 | tee >(gzip >foo.gz)
tee
with a process substitution for thegzip
command, or pee. See alsotee
for commands>(program)
syntax is new to me.