How to pipe each descriptor to different script/program

Hi all

is there a way (in sh or bash) to redirect each descriptor to different script/program

e.g. pipe stdout | grep pattern1 and stderr | grep pattern2
 
You can redirect stderr to stdout and then pipe that output through grep:
$ command 2>&1 | egrep -e "pattern1|pattern2"
 
Unix pipelines don't allow for a branch. If you want to do what you describe, you would be best off with something like:
Code:
command 2> /tmp/cmd.stderr | grep pattern1
grep pattern2 /tmp/cmd.stderr

I think that should do what you are looking for.
 
Back
Top