所以我试图在 bash 脚本中执行 if else if else 语句。截至目前,当我运行此脚本时,我收到以下错误消息“./groupJobs.sh:第 76 行:意外标记附近的语法错误 elif'./groupJobs.sh: line 76:
elif [ $jobsize -lt $2 ]; then'”
我在网上查看了多个示例,但看不出我所做的和其他人所说的有什么不同。
任何帮助,将不胜感激。
(第 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/