Consider the output:

% { echo one; echo two; echo three; } | xargs -I{} -L1 echo test-{} 
test-{} one
test-{} two
test-{} three

Why doesn't {} get substituted as per the manual page (and my memory, too)?

How to change the command line to get test-one, test-two, test-three lines as output?


Remove the -L 1; it is implied by -I (as the man page says), but it would override it when specified afterwards.


It works without "-L1", because it is implicitly set.

{ echo one; echo two; echo three; } | xargs -I{} echo test-{}

If you have GNU Parallel http://www.gnu.org/software/parallel/ installed you can do this:

{ echo one; echo two; echo three; } | parallel echo test-{}

You can install GNU Parallel simply by:

wget http://git.savannah.gnu.org/cgit/parallel.git/plain/src/parallel
chmod 755 parallel
cp parallel sem

Watch the intro videos for GNU Parallel to learn more: https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.