在脚本中执行GNU Parallel

mem*_*ecs 5 parallel-processing bash gnu gnu-parallel

从命令行parallel echo {} ::: A B C执行的命令返回正确的结果,而在bash脚本中调用时返回错误:

这是脚本:

#script.bash
#!/usr/bin/env bash

parallel echo {} ::: A B C
Run Code Online (Sandbox Code Playgroud)

这是输出:

bash script.bash
/bin/bash: {}: command not found
/bin/bash: ::: command not found
/bin/bash: A: command not found
/bin/bash: B: command not found
/bin/bash: C: command not found
Run Code Online (Sandbox Code Playgroud)

知道为什么以及如何在bash脚本中正确调用GNU parallel?

use*_*001 6

显然,当您从脚本运行它时,--tollef开关(不支持:::语法)会启用.

您可以通过启用--gnu开关来修复它

parallel --gnu echo {} ::: A B C
Run Code Online (Sandbox Code Playgroud)

  • 见男人{#}.另请阅读教程:http://www.gnu.org/software/parallel/parallel_tutorial.html (2认同)