Redirect 同时将管道连接到grep并重定向到stdout

Redirect 同时将管道连接到grep并重定向到stdout,redirect,grep,stdout,Redirect,Grep,Stdout,在Linux bash中,我尝试运行一个命令并为参数grep: command | grep 但是,我需要将commad的结果重定向到stdout,同时将其传输到grep(我需要在stdout中查看grep结果和命令的结果) 我在谷歌上搜索了一下,尝试了一些变化,例如: command | tee /dev/tty | grep 但是,没有运气 我不想用像这样的东西 command command | grep 因为它很丑:) 谢谢,试试看 command | tee >(grep

在Linux bash中,我尝试运行一个命令并为参数grep:

command | grep
但是,我需要将commad的结果重定向到stdout,同时将其传输到grep(我需要在stdout中查看grep结果和命令的结果)

我在谷歌上搜索了一下,尝试了一些变化,例如:

command | tee /dev/tty | grep
但是,没有运气

我不想用像这样的东西

command
command | grep
因为它很丑:)

谢谢,

试试看

command | tee >(grep whatever)

请注意,这两个符号之间没有空格:

谢谢,这解决了我原来的问题,但在这里添加了额外的问题是我的代码:snmpget-v2c-public 10.241.32.42.1.3.6.1.4.1.28589.2.5.96.0 | tee>(grep-E“STRING:”[0-9]\.[0-9]{3}\”;SNMPv2 SMI::enterprises.28589.2.5.96.0=“”;;echo$?;;0;;}}}}}“command | tee>(grep)的退出状态为“0”,无论grep是否成功。除了通过管道传输到grep命令的所有输出外,您希望所有输出都转到文件中的是什么?