![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| exit status of command in a pipe line | topcat8 | UNIX for Dummies Questions & Answers | 10 | 10-19-2007 05:39 AM |
| Where can I find a list of exit codes? (Exit code 64) | jkuchar747 | UNIX for Dummies Questions & Answers | 3 | 12-07-2004 06:08 PM |
| Move command return with exit code of 2 | handak9 | UNIX for Advanced & Expert Users | 1 | 08-26-2004 06:40 AM |
| Exit Code in HP-UX KSH. | mbb | High Level Programming | 3 | 03-15-2002 09:44 AM |
| All about exit code | cdin2 | Shell Programming and Scripting | 2 | 03-11-2002 10:03 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to get exit code in a pipe-lined command?
I have a question about how to get the exit code of the first command when it appears in a pipe-lined command.
For example, I have the following script: grep abc dddd | tee -a log if [[ $? -ne 0 ]] then echo "ERROR!" fi In the above script, [[ $? -ne 0 ]] is supposed to test the exit code of "grep abc dddd". But since it is in a pipe line, the $? actually stores the exit code of "tee -a log". So, [[ $? -ne 0 ]] is always false. How to address this problem? Thanks. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|