Reputation: 31258
I encountered $? in one of the shell scripts I work on integrating (not written by me).
Just wanted to confirm that it means the return code of the previous command.
The usage is something like
runSomeCommand $VAR1 $VAR2 $VAR3
processResult $?
Upvotes: 1
Views: 4025
Reputation: 96266
$?
is the exit status of the last executed command.
ls
....
echo $?
0
$ ls notexistingfile
ls: cannot access notexistingfile: No such file or directory
echo $?
2
Upvotes: 6