Splitting command line args with GNU parallel

后端 未结 3 920
一个人的身影
一个人的身影 2021-02-02 06:37

Using GNU parallel: http://www.gnu.org/software/parallel/

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

$ ./prog file1 file2
$ ./prog file         


        
3条回答
  •  野性不改
    2021-02-02 07:20

    You are looking for -n option of parallel. This is what you are looking for:

    ./generate_file_pairs | parallel -n 2 ./prog {}
    

    Excerpt from GNU Parallel Doc:

    -n max-args
        Use at most max-args arguments per command line. Fewer than max-args 
        arguments will be used if the size (see the -s option) is exceeded, 
        unless the -x option is given, in which case GNU parallel will exit.
    

提交回复
热议问题