CompTIA Linux+ (XK0-005) — Question 2
A Linux administrator was tasked with deleting all files and directories with names that are contained in the sobelete.txt file. Which of the following commands will accomplish this task?
Answer options
- A. xargs -f cat toDelete.txt -rm
- B. rm -d -r -f toDelete.txt
- C. cat toDelete.txt | rm -frd
- D. cat toDelete.txt | xargs rm -rf
Correct answer: D
Explanation
The correct answer is D because it uses 'xargs' to read filenames from 'toDelete.txt' and passes them to 'rm -rf' for deletion. Option A has an incorrect command structure, option B attempts to remove 'toDelete.txt' itself instead of its contents, and option C is syntactically incorrect as 'rm' does not accept input directly from a pipe in this manner.