Select the THREE true statements about GNU xargs.

LPIC-1 Exam 101-500, objective 103. GNU and Unix commands medium

Machine-checked — no person has signed for it. This question was read against the source cited below by an automated pass, which found no contradiction. That is a weaker claim than it sounds: the same kind of process wrote the question, so it can confirm its own mistake.

Treat it as a good draft rather than as settled fact, and read the source below before you rely on it. It is not used in mock exams here — only questions a person has signed for are.

How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.

The options

Choose 3.

Correct If no command is given, xargs runs echo with the items it read.

Correct. `xargs` alone is the documented default and is useful for turning a long list into space-separated words on a few lines.

Correct By default xargs splits its input on blanks and newlines, and quotes and backslashes in the input are honoured.

Correct, and it is the reason file names containing spaces break the naive pipeline. -0 switches to NUL separation instead.

Correct -I {} substitutes each input line for {} in the command and runs the command once per line.

Correct. The replacement string may be any word; {} is only a convention borrowed from find -exec.

Not correct xargs passes the data it reads to the command's standard input.

Wrong, and it is the point of the tool: xargs converts standard input into command-line ARGUMENTS. A plain pipe already does the standard-input case.

Not correct -P is the option that asks for confirmation before each command line is run.

Wrong. -P sets the maximum number of processes to run in parallel; the confirmation option is -p.

Not correct xargs never runs the command when it reads no items.

Wrong for GNU xargs, which runs the command once with no added arguments unless -r (--no-run-if-empty) is given.

Why

xargs exists because many commands take their operands only as arguments, and because a command line has a length limit: xargs packs as many items as will fit into each invocation and repeats the command as often as needed. Its defaults are word-oriented, so anything that may contain whitespace should be fed as NUL-separated data with a producer such as find -print0 and consumed with -0.

Where this comes from

Cited
manual page xargs(1)

Practise this

Reading one question is not practice. The trainer will draw a short set from objective 103 and space the ones you get wrong.

Practise LPIC-1 Exam 101-500

More questions on this objective

All questions on GNU and Unix commands

Practise LPIC-1 Exam 101-500