获取 xargs 序列号

VixinG

在 GNU Parallel 中,您有:

seq()    -     sequence number of job

这个我可以运行感谢wgetparallel使用:

parallel -a urls.txt -j8 wget -q {} -O '{=$_=sprintf("file%05d.ts", $job->seq())=}'

..它会像这样命名文件:

file00001.ts
file00002.ts
...
file00999.ts

现在,我怎样才能得到 的序列号xargs

例子:

xargs -P 8 -n 1 curl -O < urls.txt
奥莱·丹格

像这样:

cat urls.txt |
  parallel --shellquote |
  parallel --shellquote |
  perl -pe 's/(.*)/$1.sprintf(" -O file%05d.ts",++$t)/e' |
  xargs -P 8 -n 1 -I {} bash -c "wget {}"

--shellquote如果您的网址带有空格和 ' 等特殊字符,则需要2

http://pi.dk/? '

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章