LPIC-1 Exam 101 v5 (Linux Administrator) — Question 71
What is true regarding the command
ls > files
if files does not exist?
Answer options
- A. The output of ls is printed to the terminal
- B. files is created and contains the output of ls
- C. An error message is shown and ls is not executed
- D. The command files is executed and receives the output of ls
- E. Any output of ls is discarded
Correct answer: B
Explanation
The correct answer is B because when the command ls > files is executed and the file does not exist, the system creates the file and writes the output of ls into it. Options A, C, D, and E are incorrect because they misrepresent the behavior of the redirection operator '>' in this scenario.