Bash - (Return|Exit) (Value|Status)
Table of Contents
About
The return status (also known as Exit Status of Exit Code) of a simple command is its exit status as provided by:
Articles Related
Management
Get
? is a special parameter that expands to the status of the most recently executed foreground pipeline.
echo $?
0
Ignore
/usr/bin/somecommand || /bin/true
Snippet
Basic
RESULT=$?
if [ ${RESULT} -ne 0 ];
then
echo -e "\nLast command has failed."
else
echo -e "\nLast command has succeeded."
fi
One liner
[ "$?" -eq 0 ] && echo success || echo failure