PrepAway - Latest Free Exam Questions & Answers

Which command will print the exit value of the previous command to the screen in bash?

Which command will print the exit value of the previous command to the screen in bash?

PrepAway - Latest Free Exam Questions & Answers

A.
echo $?

B.
echo $#

C.
echo $exit

D.
echo $status

E.
echo $&

Explanation:
There are quite a few internal variables used in bash: see http://tldp.org/LDP/abs/html/internalvariables.html

Some of them are:
$! PID of last job run in background
$? Exit status of a command, function, or the script itself (see Example 24-7)
$$ PID of the script/process itself.


Leave a Reply