I have a program that writes information to stdout and stderr, and I need to process the stderr with grep, leaving
stdout
stderr
grep
This will redirect command1 stderr to command2 stdin, while leaving command1 stdout as is.
exec 3>&1 command1 2>&1 >&3 3>&- | command2 3>&- exec 3>&-
Taken from LDP