Bash 直到循环不起作用,脚本继续

Bash 直到循环不起作用,脚本继续,bash,until-loop,Bash,Until Loop,我有一个脚本,在作业完成时生成.log文件。在.log文件数等于.com文件数之前,我不希望它继续运行。目前,如果我执行这个脚本,它将启动循环,然后立即跳过实际循环,继续执行脚本 根据我从阅读中得到的信息,这个脚本没有理由不起作用。它应该在循环中被捕获,直到这两个值彼此相等 $direct是工作目录 COM="find $direct -maxdepth 1 -type f -name *.com" log="find $direct -maxdepth 1 -type f -name *

我有一个脚本,在作业完成时生成.log文件。在.log文件数等于.com文件数之前,我不希望它继续运行。目前,如果我执行这个脚本,它将启动循环,然后立即跳过实际循环,继续执行脚本

根据我从阅读中得到的信息,这个脚本没有理由不起作用。它应该在循环中被捕获,直到这两个值彼此相等

$direct是工作目录

 COM="find $direct -maxdepth 1 -type f -name *.com" 
 log="find $direct -maxdepth 1 -type f -name *.log" 
 until [[ $($COM | wc -l) = $($log | wc -l) ]];
 do
    sleep 10
 done 

 echo name EE E+ZPE E+U E+H G | cat > allRE 
 for i in R[R,S]*.out
     do echo $i | cat > $i.energies && 
     #cat temp.txt > $i.energies
     #echo $i is finished
 done 
我得到的是,它提交作业(编码到未显示的脚本的一部分),启动循环(当我查看进程列表时,我可以看到sleep命令),然后尝试执行脚本的显示部分,但发现没有.out文件(在我使用的超级计算机上开始运行作业后创建),然后继续写剧本

我被要求用-x运行它。我不知道我在寻找什么,所以这里是涉及循环的部分:

 ++ COM='find /ddn/home6/r2536/G09Input/test2/low/com -maxdepth 1 -type f -name *.com'
 ++ log='find /ddn/home6/r2536/G09Input/test2/low/com -maxdepth 1 -type f -name *.log'
 +++ find /ddn/home6/r2536/G09Input/test2/low/com -maxdepth 1 -type f -name RR1.com RR2.com RR3.com RR4.com RR5.com RR6.com SS1.com SS2.com SS3.com SS4.com SS5.com SS6.com
 +++ wc -l
 find: paths must precede expression: RR2.com
 Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
 +++ find /ddn/home6/r2536/G09Input/test2/low/com -maxdepth 1 -type f -name '*.log'
 +++ wc -l
 ++ [[ 0 = 0 ]] #if this is saying that there are no .com files, I don't get it, because the script just made and submitted 12 .com files.
 ++ echo name EE E+ZPE E+U E+H G
 ++ cat
 ++ for i in 'R[R,S]*.out'
 ++ echo 'R[R,S]*.out'
 ++ cat
 ++ grep 'SCF D' 'R[R,S]*.out'
 ++ tail -1
 grep: R[R,S]*.out: No such file or directory

这可能失败的原因有很多。请使用
-x
运行它,并记录输出和错误在
中使用双括号括起来的原因是什么。。这应该可以在移除外括号的情况下工作。@that没有显示错误,它只是在脚本下继续。@Pyrodancer123请使用
-x
运行它。例如,将
set-x
作为脚本的第二行(在shebang之后),然后将
exec>/tmp/mylog 2>&1
作为日志文件的第三行(如果在运行时无法看到输出)<代码>-x
将显示详细的输出,即使循环没有执行任何操作。如果你没有看到它,你应该去找到我看到的一件出错的事情:无引号的扩展
$COM
$log
导致
查找-名称*.com
而不是
查找-名称“*.com”
;这取决于文件名扩展,这是您不希望出现的。但实际上,您需要了解如何计算文件。