Linux Dollar Question Mark

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

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.


  1. echo $?  

Linux Doller Question Mark

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'.