An administrator needs to delete every core file under /tmp, even when the file names contain spaces, tabs, or new-line characters. She prepares the following pipeline:
The find command's -print0 flag terminates each file name with a NUL (\0) byte. xargs will still break input on any whitespace unless it is told to expect NUL-terminated items. The -0 (or --null) option does exactly that: it treats every character literally and considers only the NUL byte a delimiter, preserving embedded spaces, tabs, newlines, and quoting characters in file names.
The other choices do not solve the problem:
-n1 limits one argument per invocation but keeps the default whitespace delimiter, so names with spaces would still be split.
-d '\n' changes the delimiter to a newline only, which fails because the input is NUL-terminated, not newline-terminated.
-r (--no-run-if-empty) merely prevents the command from running on empty input; it does not change how arguments are parsed.
Therefore, -0 is the only option that guarantees each core file-regardless of embedded whitespace-is handed to rm intact.
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 does the `-print0` flag do in the find command?
Open an interactive chat with Bash
Why is the `-0` option required for xargs in this pipeline?
Open an interactive chat with Bash
How does `find -print0` and `xargs -0` work together?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access