How can I gzip standard in to a file and also print standard in to standard out?

前端 未结 4 1113
天命终不由人
天命终不由人 2020-12-14 06:28

I want to execute a command, have the output of that command get gzip\'d on the fly, and also echo/tee out the output of that command.

i.e., something like:

4条回答
  •  长情又很酷
    2020-12-14 06:59

    echo "hey hey, we're the monkees" | tee /dev/tty | gzip --stdout > my_log.gz
    

    As pointed out in the comments, /dev/stdout might work better than /dev/tty in some circumstances.

提交回复
热议问题