Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Dec 312009
 

How to adjust the argument position in xargs?

Answer:

Sometimes you might want to adjust the argument position when using the xargs command, e.g.

echo "foo" | xargs echo "bar"

It gives:

bar foo

Instead, you want the piped argument "foo" to be inserted before the "bar", you can use

echo "foo" | xargs -i echo {} "bar"

Now it gives:

foo bar

That's very handy