附近意外的标记'的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)