Which of the following commands will accomplish this task?
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?
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
Answer: D
Explanation:
The command cat toDelete.txt | xargs rm -rf will delete all files and directories with names that are contained in the toDelete.txt file. The cat command reads the file and outputs its contents to the standard output. The | operator pipes the output to the next command. The xargs command converts the output into arguments for the next command. The rm -rf command removes the files and directories recursively and forcefully. This is the correct way to accomplish the task. The other options are incorrect because they either use the wrong options (-f instead of -a for xargs), the wrong arguments (toDelete.txt instead of toDelete.txt filename for rm), or the wrong commands (rm instead of xargs).
Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 11:
Managing Files and Directories, pages 349-350.
Latest XK0-005 Dumps Valid Version with 136 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund