PIPESTATUS and EVAL - how to marry both?
Here is my question - maybe you can give me some idea about solving it:
I got commands like:
COMMAND="egrep test /tmp/alvin 2>&1 | tee /tmp/logfile ; RESULT=${PIPESTATUS[0]}";
output=$(eval $COMMAND);
How can get the exit code of the egrep command (as 0 is success or <>0 - error) to variable RESULT (and/or output) and use it in the rest of my script?
I know it is quite tricky with eval and PIPESTATUS, but maybe there is a way to do this?
Run out of ideas for the moment - can you help me out?
Last edited by Alvin88; 11-23-2015 at 05:51 PM.
Reason: correction
|