Alex Rivera | Logout

What is the $? (dollar question mark) variable in shell scripting?

Asked 2011-07-26T18:08:14.940
343

I'm trying to learn shell scripting, and I need to understand someone else's code. What is the $? variable hold? I can't Google search the answer because they block punctuation characters.

Edit
Report

2 Answers

52

That is the exit status of the last executed function/program/command. Refer to:

answered 2011-07-26T18:09:48.067
12

$? is the result (exit code) of the last executed command.

answered 2011-07-26T18:09:45.413

Your Answer