【发布时间】:2017-09-27 06:26:38
【问题描述】:
使用 if else 和 xargs 并行管道进入 gnu(对其他建议开放,查找...)
简而言之,我正在尝试编写一个脚本来检查现有文件夹并在 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}
你可以说这个脚本不起作用
对于我在脚本方面的基本知识提前道歉,非常感谢任何帮助/输入。
【问题讨论】:
标签: if-statement pipe xargs gnu-parallel