使用if其他和Xargs将GNU平行



使用elthe和xargs并行地将XARG置于gnu(向其他建议开放,找到…(

(

简而言之

我将在主题/文件列表中运行脚本,它们将通过服务器上的几个计算节点进行分发,因此命令不再在现有文件夹上写入很重要,因为相同的脚本将是在不同的节点上运行,所有节点都指向相同的目录。到目前为止,我的想法是以下内容:

为简单起见

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}

您可以说此脚本不起作用

事先对我的脚本知识表示歉意,任何帮助/输入都非常感谢。

我想做什么并不清楚100%。

我假设您要处理文件foo,并且完成此操作后,输出在bar/foo中。因此,如果bar/foo存在,您不想运行process foo

为此,GNU并行具有--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

最新更新