Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 使用gnu并行运行循环并传入变量_Bash_Gnu Parallel - Fatal编程技术网

Bash 使用gnu并行运行循环并传入变量

Bash 使用gnu并行运行循环并传入变量,bash,gnu-parallel,Bash,Gnu Parallel,我需要通过GNUparallel为dir中的每个元素运行bash函数。我需要访问此函数的evn变量。我怎么通过呢。例如,在shell脚本中执行以下代码。我有一个变量DIRS=/folder/log。如何将“DIRS”传递给函数readfile\ux。提前谢谢 export SHELL=$(type -p bash) function readfile_ {do something} export -f readfile_ ls -d */ | grep -v errlogs | paral

我需要通过GNUparallel为dir中的每个元素运行bash函数。我需要访问此函数的evn变量。我怎么通过呢。例如,在shell脚本中执行以下代码。我有一个变量DIRS=/folder/log。如何将“DIRS”传递给函数readfile\ux。提前谢谢

export SHELL=$(type -p bash)
function readfile_ {do something}

export -f readfile_ 
ls -d */ | grep -v errlogs |  parallel readfile_ 
我明白了


--env
仅在远程运行命令时才需要。否则,
导出
。如果使用版本20140822和
env_parallel
函数,您甚至可以忽略
导出
:www.gnu.org/software/parallel/man.html(在--env下)@OleTange谢谢。就像这样:parallel--env uu读取文件。在这行之前需要“parallel--record env”。
DIRS=/folder/log
export DIRS
ls -d */ | grep -v errlogs |  parallel --env DIRS readfile_