If statement 使用if-else和xargs将管道导入gnu并行
使用if-else和xargs将管道连接到gnu并行(开放给其他建议,查找…) 简言之,我试图编写一个脚本来检查现有文件夹,并在gnu并行中运行一个命令(不存在的文件夹/文件的脚本)(对其他建议开放) 我将为主题/文件列表运行脚本,它们将分布在服务器上的多个计算节点上,因此命令不要再次写入现有文件夹,因为相同的脚本将在不同节点上运行,并且所有节点都指向相同的目录。到目前为止,我的想法如下: 为了简单起见If statement 使用if-else和xargs将管道导入gnu并行,if-statement,pipe,xargs,gnu-parallel,If Statement,Pipe,Xargs,Gnu Parallel,使用if-else和xargs将管道连接到gnu并行(开放给其他建议,查找…) 简言之,我试图编写一个脚本来检查现有文件夹,并在gnu并行中运行一个命令(不存在的文件夹/文件的脚本)(对其他建议开放) 我将为主题/文件列表运行脚本,它们将分布在服务器上的多个计算节点上,因此命令不要再次写入现有文件夹,因为相同的脚本将在不同节点上运行,并且所有节点都指向相同的目录。到目前为止,我的想法如下: 为了简单起见 SUBJ_LIST=(a text file with list of subjects/f
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
,则不希望运行processfoo
为此,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
我不完全清楚你想做什么 我假设您想要处理文件
foo
,完成后,输出在bar/foo
中。因此,如果存在bar/foo
,则不希望运行processfoo
为此,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
美女非常有效是的,这正是我想要做的。我不知道parallel内置了这个功能。非常感谢。美女非常有效是的,这正是我想要做的。我不知道parallel内置了这个功能。非常感谢。