Javatpoint Logo
Javatpoint Logo

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.

Syntax:

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



Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA