所以我试图在 bash 脚本中执行 if else if else 语句。截至目前,当我运行此脚本时,我收到以下错误消息“./groupJobs.sh: line 76: syntax error near unexpected token elif'
./groupJobs.sh:第 76 行:
elif [ $jobsize -lt $2 ];那么'"
我在网上查看了多个示例,看不出我所做的与其他人所说的有任何区别。
如有任何帮助,我们将不胜感激。 (第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
语句需要一个实际的语句。暂时将 echo "job creation done"
和 echo "add file to job"
之类的内容放入这些语句(或您想要的任何其他内容)中......
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
echo "whatever you want"
#the above line just has to be some sort of actual statement
elif [ $jobsize -lt $2 ]; then
#add file to job and move on to next file check
echo "whatever you want"
#the above line just has to be some sort of actual statement
fi
关于linux - Bash 脚本如果 elif elif 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22996127/