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.