所以我想在bash脚本中做一个if else else if语句。截至目前,当我运行此脚本时,出现以下错误消息:“./groupJobs.sh:line 76:语法错误附近出现了令牌elif' ./groupJobs.sh: line 76:
elif [$ jobsize -lt $ 2];然后''Bash脚本如果elif elif不工作
我已经在线在多个例子中,在我所做的和别人说的作品中看不到任何区别。
任何帮助,将不胜感激。 (线76是最后的elif语句)
if [ $filesize -ge $2 ]; then
#goes this way if file is to big to put in a job with anyother files
$filename >> $jobname$jobnumber;
elif [ $jobsize -ge $2 ]; then
#job is done being created
elif [ $jobsize -lt $2 ]; then
#add file to job and move on to next file check
fi
错误消息看起来像'elif'和'['之间可能没有空格。在你的代码abve中看起来没问题。我会移动';'字符,所以有一个空格将它们从'''分开,但可能没有必要。并且它从不会伤害到将所有变量包装在dbl引号中,即。 '“$ filename”>>“$ jobname $ jobnumber”'。祝你好运。 – shellter
欢迎来到bash标签!请查看[tag wiki](http://stackoverflow.com/tags/bash/info),以获取提示之前要做什么的好提示。在这种情况下,[shellcheck](http://www.shellcheck.net)将有助于查明问题。 –