Multiple arguments using xargs.

catcurlxargs

I know xargs can take many arguments like so.

xargs -n5 -I{} echo {}

but how do I put the arguments in a particular location I want do something like.

xargs -n5 -I{} curl www.google.com/{1}/testing/{2}/{3}/works/{5}

How can something like that be achieved?

Best Answer

I don't think you can do this directly with xargs. Either use read as Costas suggests, or do:

xargs -n5 sh -c 'curl "http://www.google.com/${1}/testing/${2}/${3}/works/${5}"' curl-command

Or build the URL, then pass it to xargs:

awk '{printf "http://www.google.com/%s/testing/%s/%s/works/%s\n", $1, $2, $3, $5}' | \
  xargs -L1 curl 
Related Question