Eonil Asked: 2010-06-30 00:04:20 +0800 CST2010-06-30 00:04:20 +0800 CST 2010-06-30 00:04:20 +0800 CST How can I download multiple files stored in a text file with curl and xargs? 772 How can I download multiple files stored in a text file with curl and xargs? This is my last trial: cat listfile.txt | xargs curl -O first file works well, but other files are just output to stdout. curl xargs 3 Answers Voted Ole Tange 2010-06-30T06:45:11+08:002010-06-30T06:45:11+08:00 Using GNU Parallel http://www.gnu.org/software/parallel/ you can do: cat listfile.txt | parallel curl -O Not only does GNU Parallel deal nicely with special chars like ' " and space, you will also get the added benefit of downloading in parallel. Watch the intro video to GNU Parallel: http://www.youtube.com/watch?v=OpaiGYxkSuQ Best Answer Eonil 2010-06-30T00:09:14+08:002010-06-30T00:09:14+08:00 I found solution: cat ./../c | xargs -n1 curl -O xargs splits stdin by spaces and newlines, and passes to curl at once. So curl called only once with long arguments. n1 option limits this passing argument count as 1, so curl will be called multiple times. Zizzencs 2010-06-30T00:21:29+08:002010-06-30T00:21:29+08:00 xargs doesn't know what curl is so it can't determine how many arguments it should pass in one round. So the solution is to pass a -n1 option to it as you mentioned.
Using GNU Parallel http://www.gnu.org/software/parallel/ you can do:
Not only does GNU Parallel deal nicely with special chars like ' " and space, you will also get the added benefit of downloading in parallel.
Watch the intro video to GNU Parallel: http://www.youtube.com/watch?v=OpaiGYxkSuQ
I found solution:
xargs splits stdin by spaces and newlines, and passes to curl at once. So curl called only once with long arguments.
n1
option limits this passing argument count as 1, so curl will be called multiple times.xargs doesn't know what curl is so it can't determine how many arguments it should pass in one round. So the solution is to pass a -n1 option to it as you mentioned.