Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simultaneous pipe to grep and redirect to stdout

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,

like image 590
Aman Avatar asked Apr 14 '14 17:04

Aman


1 Answers

Try

command | tee >(grep whatever)

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

like image 129
ooga Avatar answered Nov 04 '22 08:11

ooga