Los Angeles1
asked on
Linux scripting question, return code of last command
How do I determine the return code of the last command
I want to know if it was successful or not
I want to know if it was successful or not
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could do
if [ $? -eq 0 ]; then
echo "Command succeeded!"
# Some more action to celebrate this success ...
else
echo "Command failed"
# More action to bemoan this failure ...
fi
if [ $? -eq 0 ]; then
echo "Command succeeded!"
# Some more action to celebrate this success ...
else
echo "Command failed"
# More action to bemoan this failure ...
fi
echo $?
if result is 0 (zero) then last command was successful