What does $? Mean in shell script?
Madison Flores
Published May 12, 2026
.
Similarly, you may ask, what does $? Mean in Shell?
= was last command successful. Answer is 0 which means 'yes'.
One may also ask, what does $? Do in Linux? variable represents the exit status of the previous command. Exit status is a numerical value returned by every command upon its completion. As a rule, most commands return an exit status of 0 if they were successful, and 1 if they were unsuccessful.
what does $? Mean in bash?
$0 is one of the most used bash parameters and used to get the exit status of the most recently executed command in the foreground. By using this you can check whether your bash script is completed successfully or not.
What is $1 and $2 in shell script?
what is $1. $1 is the first commandline argument. If you run ./asdf.sh a b c d e, then $1 will be a, $2 will be b, etc. In shells with functions, $1 may serve as the first function parameter, and so forth.
Related Question Answers