How can I pass all arguments with xargs in middle of command in linux

user2027303 picture user2027303 · Feb 1, 2013 · Viewed 25.8k times · Source

I want to pass all the files as a single argument on Linux but I am not able to do that.

This is working

ls | sort -n | xargs  -i pdftk  {} cat output combinewd2.pdf

This passes a single argument per command, but I want all in one command.

Answer

Hongbo Liu picture Hongbo Liu · Nov 1, 2016

Use -I option:

echo prefix | xargs -I % echo % post

Output:

prefix post