使用 if else 和 xargs 管道进入 gnu parallel
Using if else and xargs to pipe into gnu parallel
使用 if else 和 xargs 管道进入 gnu parallel(接受其他建议,找到…)
简而言之,我正在尝试编写一个脚本来检查现有文件夹和 运行 一个命令(不存在 folders/files 的脚本)在 gnu 并行(接受其他建议)
我将为 subjects/files 的列表编写脚本 运行,它们将分布在服务器上的多个计算节点上,因此重要的是命令不会覆盖现有文件夹再次作为相同的脚本将在不同的节点上 运行 并且它们都指向相同的目录。到目前为止,我的想法如下:
为简单起见[=11=]
SUBJ_LIST=(a text file with list of subjects/files to be executed .txt)
SUBJ_EXIST=(folder that the program outputs to)
SUBJ_tp_do= (hopefully only subjects/files that have not been done)
cat ${SUBJ_LIST} | xargs -I{} -n 1 if [ -d ${SUBJ_EXIST}/{} ]
then
echo "folder exists"
else
SUBJ_tp_do={}
fi
parallel -j8 command {} ::: ${SUBJ_to_do}
如您所知,此脚本不起作用
提前为我对脚本的基本知识表示歉意,非常感谢任何help/input。
我不是 100% 清楚你想做什么。
我假设您要处理文件 foo
,完成后输出在 bar/foo
中。所以如果 bar/foo
存在,你不想 运行 process foo
.
为此,GNU Parallel 有 --resume
和 --results
:
$ parallel --results bar/{} --resume -v echo ::: a b c
echo a
a
echo b
b
echo c
c
$ parallel --results bar/{} --resume -v echo ::: a b c
<<no output - nothing was run>>
$ parallel --results bar/{} --resume -v echo ::: 1 a b 2 3 c
echo 1
1
echo 2
2
echo 3
3
请注意在最后 运行 中如何跳过 a、b 和 c。
如果 a、b 和 c 在文件中,您只需替换为:
parallel ... :::: inputfile.txt
使用 if else 和 xargs 管道进入 gnu parallel(接受其他建议,找到…)
简而言之,我正在尝试编写一个脚本来检查现有文件夹和 运行 一个命令(不存在 folders/files 的脚本)在 gnu 并行(接受其他建议)
我将为 subjects/files 的列表编写脚本 运行,它们将分布在服务器上的多个计算节点上,因此重要的是命令不会覆盖现有文件夹再次作为相同的脚本将在不同的节点上 运行 并且它们都指向相同的目录。到目前为止,我的想法如下:
为简单起见[=11=]
SUBJ_LIST=(a text file with list of subjects/files to be executed .txt)
SUBJ_EXIST=(folder that the program outputs to)
SUBJ_tp_do= (hopefully only subjects/files that have not been done)
cat ${SUBJ_LIST} | xargs -I{} -n 1 if [ -d ${SUBJ_EXIST}/{} ]
then
echo "folder exists"
else
SUBJ_tp_do={}
fi
parallel -j8 command {} ::: ${SUBJ_to_do}
如您所知,此脚本不起作用
提前为我对脚本的基本知识表示歉意,非常感谢任何help/input。
我不是 100% 清楚你想做什么。
我假设您要处理文件 foo
,完成后输出在 bar/foo
中。所以如果 bar/foo
存在,你不想 运行 process foo
.
为此,GNU Parallel 有 --resume
和 --results
:
$ parallel --results bar/{} --resume -v echo ::: a b c
echo a
a
echo b
b
echo c
c
$ parallel --results bar/{} --resume -v echo ::: a b c
<<no output - nothing was run>>
$ parallel --results bar/{} --resume -v echo ::: 1 a b 2 3 c
echo 1
1
echo 2
2
echo 3
3
请注意在最后 运行 中如何跳过 a、b 和 c。
如果 a、b 和 c 在文件中,您只需替换为:
parallel ... :::: inputfile.txt