LPIC-1 Exam 101 v5 (Linux Administrator) — Question 77
Which of the following commands creates or, in case it already exists, overwrites a file called data with the output of ls?
Answer options
- A. ls 3> data
- B. ls >& data
- C. ls > data
- D. ls >> data
- E. ls >>> data
Correct answer: C
Explanation
The correct answer is C, as 'ls > data' directs the output of ls into the file data, creating it if it doesn't exist or overwriting it if it does. Option A is incorrect because '3>' is used for redirecting file descriptor 3, which is not standard for this purpose. Option B is wrong as '>&' is used for duplicating file descriptors, while D appends the output instead of overwriting, and E is not a valid command syntax.