Multiple choice technology operating systems

Which of the following will return the exit code of the last executed command?

  1. $%
  2. $#
  3. $?
  4. $!
Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In shell scripting, special variables hold specific information: $? contains the exit code of the last executed command, $# contains the number of arguments, $! contains the PID of the last background command, and $% is not a standard special variable. To check if a command succeeded, you typically check if $? equals 0.