0

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) ?

4

2 回答 2

1

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

于 2010-09-29T20:02:33.933 回答
0

无法试一试,但就像 Gabriel 和 Bob 指出的那样,命令 $ tee (man tee)会帮助你。tee 命令将接受输入并将其回显到标准输出以及文件。正如鲍勃在评论中所说:

cat foo.txt | grep -v foo | grep -v bar | tee -a inspection.txt | grep -v baz

将从中获取输出grep -v bar并将其放入标准输出以及inspection.txt。-a 标志使其附加到检查而不是创建一个全新的文件。

于 2010-09-30T05:46:15.533 回答