gpt4 book ai didi

linux - Bash 脚本如果 elif elif 不工作

转载 作者:IT王子 更新时间:2023-10-29 01:00:52 30 4
gpt4 key购买 nike

所以我试图在 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com