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?
D. cat toDelete.txt | xargs rm -rf
The "cat toDelete.txt" command will display the contents of the "toDelete.txt" file, which contains the names of the files and directories to be deleted. The "xargs rm -rf" command will take the standard input from the "cat" command and pass it as arguments to the "rm" command. The "-rf" options of the "rm" command are used to forcibly delete the specified files and directories, including any files and directories within them, even if they are write-protected. The "xargs" command is used here to process the input one line at a time and execute the "rm" command for each line.
The rm command will do nothing to act on the contents of the file without help. As written rm will remove the file in question. You need to expose the contents of the file to rm in order for it to act on them. Either cat the file and hand it off to xargs or "xargs rm -rf < file" or cat it , send it to awk and let awk pass the contents to rm.
D. `xargs` builds and executes command lines from standard input. Assuming the file, toDelete.txt, contains one file name per line, this works. The other answers are nonsense.
D is the correct answer. The selected answer delete the file. with answer D it removes the files listed inside the file. xargs - build and execute command lines from standard input.
I'm pretty sure this one is D. Option B just removes the file, but the question asks to remove files & directories "listed inside" the file. Just tested this out on my Linux machine ... It's D
I didn't know one can have a directory inside a file, I thought it was the other way around, directories can contains file but file cannot contain directories, actually as B option states if you provide the options listed you can accomplish the task with no problem, i just tested it and it works fine.
No, a directory is always a directory, i tested B with all the options and it works perfect on centOS 9
upvoted 1 times
...
...
...
...
This section is not available anymore. Please use the main Exam Page.XK0-005 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
linux_admin
Highly Voted 1 year, 9 months agobc1235813
Most Recent 8 months agoe418137
9 months agoNvoid
1 year, 11 months agoNvoid
1 year, 11 months agoryanzou
2 years agoTheRealManish
2 years agoAamm033
2 years agobjornborg
2 years agoVeteran903
1 year, 12 months agoNvoid
1 year, 11 months agoVeteran903
1 year, 11 months ago