Simultaneous pipe to grep and redirect to stdout

随声附和 提交于 2020-01-22 20:50:10

问题


In Linux bash, I am trying to run a command and grep for an argument:

command | grep

However, I need to redirect the result of the commad to the stdout and simultaneously pipe it to grep (I need to see both the grep result and the command result in stdout).

I googled a bit and tried some variations, such as:

command | tee /dev/tty | grep

But, no luck.

I don't want to use sth like

command
command | grep

as it is ugly :)

Thanks,


回答1:


Try

command | tee >(grep whatever)

Note that there's no space between these two symbols: >(.



来源:https://stackoverflow.com/questions/23066559/simultaneous-pipe-to-grep-and-redirect-to-stdout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!