使用gnu-parallel处理文件内容

时间:2018-08-14 17:13:03

标签: bash gnu-parallel

我有一个文件,其内容如下:

/path/to/file1
/path/to/file2
/path/to/file3
/path/to/file4

我想使用gnu-parallel实用程序在每行上并行运行命令,我知道它支持使用::::进行文件输入。我不确定的是,我应该将哪些参数传递给gnu-parallel,以\n分割文件内容并并行处理?

1 个答案:

答案 0 :(得分:3)

这里是man parallel

NAME
       parallel - build and execute shell command lines from
       standard input in parallel

SYNOPSIS
       parallel [options] [command [arguments]] < list_of_arguments
       [...]

这是这种调用形式的一个示例:

$ cat mylist.txt
/path/to/file1
/path/to/file2
/path/to/file3
/path/to/file4

$ parallel 'echo "I am processing:" {}' < mylist.txt
I am processing: /path/to/file1
I am processing: /path/to/file2
I am processing: /path/to/file3
I am processing: /path/to/file4
相关问题