附近意外的标记'的elif'语法错误 [英] Syntax error near unexpected token 'elif'
本文介绍了附近意外的标记'的elif'语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#!/bin/bash
if [ "$1" = "boot" ]
then
if [ -f /var/log/boot.log ]
then
echo /var/log/boot.log
elif [ -f /var/log/boot ]
then
echo /var/log/boot
fi
fi
这显示输出:
: command not foundline 8: GetLogfileName.sh: line 15: syntax error
near unexpected token `elif' 'etLogfileName.sh: line 15: `
elif [ -f /var/log/boot ]
这是怎么回事错在这里?
What is going wrong here?
推荐答案
乱码错误信息表明您的文件有换行符之前回车。你在Windows上编辑你的脚本?要么使用文本编辑器来保存该文件没有回车或通过 DOS2UNIX的
运行脚本(或者 D2U
)
The garbled error message indicates your file has carriage returns before the newline. Did you edit your script on Windows? Either use your text editor to save the file without carriage returns or run the script through dos2unix
(or perhaps d2u
)
这篇关于附近意外的标记'的elif'语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文