LPIC-1 Exam 101 v5 (Linux Administrator) — Question 19

Which of the following commands displays the output of the foo command on the screen and also writes it to a file called /tmp/foodata?

Answer options

Correct answer: D

Explanation

The correct answer is D because the tee command allows the output of foo to be displayed on the screen and written to /tmp/foodata at the same time. Option A incorrectly uses less, which only displays output without saving it. Option B tries to use cp, which is not applicable for capturing command output. Option C only redirects output to the file, missing the display on the screen, and option E has incorrect syntax for redirection.