nerdexam
CompTIA

XK0-005 · Question #526

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?

The correct answer is D. cat toDelete.txt | xargs rm -rf. 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…

System Management

Question

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?

Options

  • Axargs -f cat toDelete.txt -rm
  • Brm -d -r -f toDelete.txt
  • Ccat toDelete.txt | rm -frd
  • Dcat toDelete.txt | xargs rm -rf

How the community answered

(34 responses)
  • A
    3% (1)
  • B
    6% (2)
  • D
    91% (31)

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.

Topics

#xargs#rm command#Pipes#File system management

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice