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

前端 未结 4 1110
天命终不由人
天命终不由人 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 07:07

    Just to post a way that doesn't involve touching disk:

    echo "hey hey, we're the monkees" | (exec 1>&3 && tee /proc/self/fd/3 | gzip --stdout > my_log.gz)
    

提交回复
热议问题