CompTIA Linux+ (XK0-004) — Question 179
A systems administrator needs to append output of ls `"lha /opt command to the contents of a test.txt file. Which of the following commands will accomplish this?
Answer options
- A. ls ג€"lha /opt > test.txt
- B. ls ג€"lha /opt < test.txt
- C. ls ג€"lha /opt >> test.txt
- D. ls ג€"lha /opt << test.txt
Correct answer: C
Explanation
The correct command is C, as using '>>' appends the output to the specified file instead of overwriting it. Option A uses '>', which would replace the contents of test.txt instead of adding to it. Option B incorrectly uses '<', which is intended for input redirection, not output. Option D uses '<<', which is not a valid operation for this purpose.