I'm trying to pipe a list of values through xargs
. Here's a simple example:
echo "Hello Hola Bonjour" | xargs -I _ echo _ Landon
I would expect this to output the following:
Hello Landon
Hola Landon
Bonjour Landon
Instead, the command outputs this:
Hello Hola Bonjour Landon
What am I missing?
Under -I
, man xargs
says
unquoted blanks do not terminate input items; instead the separator is the newline character
You can specify a different delimiter (at least in GNU xargs):
printf 'Hello Hola Bonjour' | xargs -d' ' -I _ echo _ Landon
More portably, use \0
as the delimiter and -0
to use it:
printf '%s\0' Hello Hola Bonjour | xargs -0 -I _ echo _ Landon