If I have a process a.outI can do ./a.out | grep footo see stdout a.out filtered by foo. I can also say ./a.out 2>&1 | grep footo see both err and out filtered by foo. Using the command, teeI can send stdout both to the terminal and, possibly, to a file. But is there a way to filter them separately? how in:
./a.out | tee grep foo file.txt
but what goes on file.txtis filtered to match foo, but not what I see on the screen ... or even better than what I see on the screen, is baz filtered instead of foo? If in bash there is no way to do this, I would write my own "tee", but I would suggest that there is some way ...
source
share