1: #!/bin/sh 2: # Example 14 3: # Take stderr from a command and pass it into a pipe 4: # for further processing. 5: 6: # Uses ex13.sh to generate some output to stderr 7: # stdout of ex13 is processed normally 8: 9: # Save a copy of original stdout 10: exec 3>&1 11: 12: # stdout from ex13.sh is directed to the original stdout (3) 13: # stderr is passed into the pipe for further processing. 14: # stdout from the pipe is redirected back to stderr 15: ./ex13.sh 2>&1 1>&3 3>&- | sed 's/stderr/STDERR/' 1>&2 16: 17: # 3 is closed before running the command, just in case it cares 18: # about inheriting open file descriptors.
last modified 22/03/2012 | Introduction | Table of Contents (frame/no frame) |
Printable (single file) |
© Dartmouth College |