I ivand58 Sep 13, 2010 #1 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
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
phoenix Sep 13, 2010 #2 You can redirect stderr to stdout and then pipe that output through grep: $ command 2>&1 | egrep -e "pattern1|pattern2"
You can redirect stderr to stdout and then pipe that output through grep: $ command 2>&1 | egrep -e "pattern1|pattern2"
G gordon@ Developer Sep 14, 2010 #3 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.
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.