Let\'s say I do this in a unix shell
$ some-script.sh | grep mytext $ echo $?
this will give me the exit code of grep
grep
If you're using bash:
PIPESTATUS An array variable (see Arrays) containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command).