我怎样才能gzip压缩标准中的文件以及在标准打印标准输出? [英] How can I gzip standard in to a file and also print standard in to standard out?
本文介绍了我怎样才能gzip压缩标准中的文件以及在标准打印标准输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要执行命令,有命令的输出上飞得到gzip压缩,同时也呼应/发球出命令的输出。
即,是这样的:
回声嘿,我们是顽童合唱团| gzip的--stdout> my_log.gz
除行执行的时候,我希望看到这个标准出来:
嘿嘿,我们是顽童合唱团
解决方案
回声嘿,我们是顽童合唱团|三通的/ dev / tty的| gzip的--stdout> my_log.gz
由于在评论中指出,的/ dev /标准输出
可能工作比的/ dev / tty的
在一些更好的情况。
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:
echo "hey hey, we're the monkees" | gzip --stdout > my_log.gz
Except when the line executes, I want to see this on standard out:
hey hey, we're the monkees
解决方案
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.
这篇关于我怎样才能gzip压缩标准中的文件以及在标准打印标准输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文