从链接应用程序中间检查标准输出
考虑这个示例链:
cat foo.txt | grep -v foo | grep -v bar | grep -v baz
我想检查第二个 grep 的内容 stdout 以及生成的 stdout:
cat foo.txt | grep -v foo | grep -v bar | UNKNOWN | grep -v baz
所以我需要一个未知的工具,例如将 stdout 的内容转储到文件中,并将 stdout 沿着链。
该工具(未知)是否存在(Windows 和 Linux 答案都相关)?
Consider this example chain:
cat foo.txt | grep -v foo | grep -v bar | grep -v baz
I'd like to inspect the contents stdout of the second grep as well as the resulting stdout:
cat foo.txt | grep -v foo | grep -v bar | UNKNOWN | grep -v baz
So I need a tool, UNKNOWN, that for instance dumps the contents of stdout to a file and also passes stdout along the chain.
Does the tool, UNKNOWN, exists (both Windows and Linux answers are relevant) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为有一种叫做“Tee”的东西可以给你这样的感觉。
更新反映鲍勃的评论:
猫 foo.txt | grep -v foo | grep -v foo | grep -v foo | grep -v foo | grep -v foo | grep grep -v 栏 | tee -a 检查.txt | grep -v 巴兹
I think there's a thing call 'tee' that gives you that.
Update reflecting comment from Bob:
cat foo.txt | grep -v foo | grep -v bar | tee -a inspection.txt | grep -v baz
无法尝试,但就像 Gabriel 和 Bob 指出的那样,命令 $ tee (man tee) 会帮助你的。 tee 命令将接受输入并将其回显到标准输出以及文件。正如 Bob 在他的评论中所说:
将从 grep -v bar 获取输出并将其放入 stdout 以及 Inspection.txt。 -a 标志使其附加到检查中,而不是创建一个全新的文件。
Unable to give it a shot, but like Gabriel and Bob pointed out, the command $ tee (man tee) will help you out. The tee command will take input and echo it to stdout, as well as files. As Bob said in his comment:
Will take the output from
grep -v bar
and put it to stdout, as well as inspection.txt. The -a flag causes it to append to inspection rather than create a whole new file.