这是一个curl
示例xargs
:
$ cat URLS.txt | xargs -P 10 -n 1 curl
上面的示例应将curl
每个URL并行,每次10个。在-n 1
那里,因此每次执行xargs
仅使用URLS.txt
文件中的1行curl
。
每个xargs参数的作用是:
$ man xargs
-P maxprocs
Parallel mode: run at most maxprocs invocations of utility at once.
-n number
Set the maximum number of arguments taken from standard input for
each invocation of utility. An invocation of utility will use less
than number standard input arguments if the number of bytes
accumulated (see the -s option) exceeds the specified size or there
are fewer than number arguments remaining for the last invocation of
utility. The current default value for number is 5000.