[英]Pipe output with tee & grep into file but seeing full output
Trying to get the output of a grep written into a file while having the by grep non-affected output in terminal.尝试将 grep 的输出写入文件,同时让 by grep 在终端中不受影响的输出。
Example:例子:
command:命令:
cat file | grep 'aaa' >> any.txt #Missing parameters here
desired output in terminal:终端所需的输出:
aaa
bbb
ccc
redirected into any.txt重定向到 any.txt
aaa
那么也许不是 grep,你可以使用awk
代替:
cat file | awk '/aaa/{print >>"output.txt";}1'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.