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

标签 linux bash

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

相关文章:

bash - 如何在 pg_dump 中传递日志文件

linux - 如何组成矩阵表

linux - 如何知道系统是否完全空闲

regex - 如何用动态变量替换 sed 反向引用

python - 解析 ICINGA status.dat 文件

bash - 如何使用 bash 删除文件中只出现一次的行

ruby-on-rails - 为什么我在安装 RVM 时会出现权限错误?

c++ - 如何有效运行后台数据处理和记录(Debian、Beaglebone Black)

linux - grep初始空间

linux - 在 unix 或 shell 中将新行打印为字符串文字