An administrator runs the following command to generate a list of temporary files:
find /home/project -type f -name '*.tmp' -print0
The list is piped to another command to remove the files. Which of the following completes the pipeline so that filenames containing spaces or newlines are handled safely?
The correct choice uses xargs -0 rm, which tells xargs to read null-terminated input (-0) that matches the -print0 output from find. This guarantees that embedded whitespace and newline characters in filenames do not split arguments.
The other options are incorrect:
xargs rm uses the default whitespace delimiter, so any space in a filename would cause it to be broken into multiple arguments.
xargs -d '\n' rm forces newline delimiting, which still fails on filenames containing spaces.
xargs -n 1 rm runs rm once per argument but still suffers from the same whitespace-splitting problem because the delimiter remains whitespace/newline.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the `xargs` command in Linux?
Open an interactive chat with Bash
How does `xargs` handle spaces or special characters in input?