Standard input contains alpha, beta, and gamma separated by spaces or newlines.
Pass them as arguments to echo in one or more command executions; names contain no spaces or quotes.
Which filter is correct?
xargs reads items from standard input, builds an argument list, and runs another command. Its default parsing treats whitespace as separators.
Detailed explanation
xargs echoCorrect. xargs constructs echo's arguments from the input items.
Correct. xargs constructs echo's arguments from the input items.
tee echoIncorrect. tee copies input to output and does not construct an argument list.
Incorrect. tee copies input to output and does not construct an argument list.
echo | xargsIncorrect. This gives xargs no input from the intended stream and does not invoke echo with the items.
Incorrect. This gives xargs no input from the intended stream and does not invoke echo with the items.
cat echoIncorrect. cat reads files; it does not turn input words into echo arguments.
Incorrect. cat reads files; it does not turn input words into echo arguments.
Try it yourself
An example you can run in a temporary verification environment.
printf 'alpha
beta
gamma
' | xargs echoExpected result
alpha beta gammaKey points
- Convert standard input to arguments
- Whitespace is the default delimiter
- Long input may be split into multiple executions
Notes
- Environment: GNU findutils 4.x
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.