Lpic 1 Linux Administrator · Free Practice Question Easy
Question 16
- A The exit status of the most recently executed command
- B The output of the previous echo command
- C The process ID of the most recent background job
- D The name of the current shell
Reveal correct answer
Correct answer: A
A. The command echo $? outputs the exit status of the most recently executed command in the shell. This is useful for checking whether a command was successful or not, as most commands return an exit status of 0 for success and non-zero for failure.
B. The command echo $? does not output the output of the previous echo command. It specifically retrieves and displays the exit status of the most recently executed command in the shell.
C. The command echo $? does not output the process ID of the most recent background job. It is solely used to display the exit status of the previous command executed in the shell.
D. The command echo $? does not output the name of the current shell. It is specifically used to display the exit status of the most recently executed command in the shell.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
