Linux Dollar Question Mark ($?)
This control operator is used to check the status of last executed command. If status shows '0' then command was successfully executed and if shows '1' then command was a failure.
The exit code of the previous command is stored in the shell variable $?. It is a shell parameter and not a variable as you can't assign a value to it.
Look at the above snapshot, at first time, all the directories have been deleted successsfully and hence $? shows the value '0'.But in the second time, command was failed to delete the directories and hence shows the value '1'.