Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 8 down vote accepted

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

share|improve this answer

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

{ echo one; echo two; echo three; } | xargs -I{} echo test-{}
share|improve this answer

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

share|improve this answer
+1, this is a nice script. – ulidtko May 9 '12 at 22:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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