拆分命令行参数与GNU并行 [英] Splitting command line args with GNU parallel

查看:146
本文介绍了拆分命令行参数与GNU并行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 GNU并行的http:// www.gnu.org/software/parallel/

我有一个程序,有两个参数,例如

I have a program that takes two arguments, e.g.

$ ./prog file1 file2
$ ./prog file2 file3
...
$ ./prog file23456 file23457

我使用生成的文件名对一个剧本,但是因为脚本的结果是一个字符串这带来一个问题 - 不是一对。这样的:

I'm using a script that generates the file name pairs, however this poses a problem because the result of the script is a single string - not a pair. like:

$ ./prog "file1 file2"

GNU并行似乎有招数起袖子摆,我不知道是否有一个分隔符周围文本拆分:

GNU parallel seems to have a slew of tricks up its sleeves, I wonder if there's one for splitting text around separators:

$ generate_file_pairs | parallel ./prog ?  
  # where ? is text under consideration, like "file1 file2"

最简单的解决办法是在手动PROG分裂ARGS,但我想知道是否有可能在 GNU并行

推荐答案

您可能正在寻找 - COLSEP

generate_file_pairs | parallel --colsep ' ' ./prog {1} {2}  

男子平行更多。并观看了介绍视频,如果你还没有这样做的 http://www.youtube.com/watch?v=OpaiGYxkSuQ

Read man parallel for more. And watch the intro video if you have not already done so http://www.youtube.com/watch?v=OpaiGYxkSuQ

这篇关于拆分命令行参数与GNU并行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆