Check previous error status
This statement works if there is an error within the last command in
Line 01. I have to modify the code in Line 02 so that it checks for
errors in previous statements in Line 01. I want to get the error status
for previous commands in the statement in Line 01 such as the error
status for the command 'cat $ORA_LIST_FILE'. How to do it?
01 cat $ORA_LIST_FILE | wc -l 1> $ORA_LIST_COUNT_FILE_TMP 2>>
02 if [ ! $? -eq 0 ]; then
Even if you capture the output in an environment variable, you should be able to find the status in $?.
if [ $? -eq 0 ]; then
echo "Impossible file found."
echo "Impossible file not found."
The only return value available is that of the last command in a pipeline.
Your problem should go away if you skip catting the file out. Just use wc.
Indeed: 'useless use of cat', also, don't use
[[ ! $? -eq 0 ]]
[[ $? -ne 0 ]]
PS Matir is correct also
|All times are GMT -5. The time now is 02:16 PM.|