我在这里尝试编写可以在特定日期运行的 shell,Sun Solaris 10 不支持新功能,但我不断收到syntax error near unexpected token
elif'`
DAY_Word=$(date +%A)
Nomral_Day=$(date +%d)
MONTH=$(date +%m)
if [ "$Nomral_Day" -eq 01 ] || [ "$Nomral_Day" -eq 16 ] && [ "$MONTH" -ne 02 ]
then
###run integrity after
elif [ "$Nomral_Day" -eq 12 ] || [ "$Nomral_Day" -eq 28 ] && [ "$DAY_Word" = "Thursday" ] && [ "$MONTH" -ne 02 ]
then
### run integrity before
elif [ "$Nomral_Day" -eq 13 ] || [ "$Nomral_Day" -eq 29 ] && [ "$DAY_Word" != "Friday" ] && [ "$MONTH" -ne 02 ]
then
### run integrity before
elif [ "$Nomral_Day" -eq 25 ] && [ "$DAY_Word" = "Thursday" ] && [ "$MONTH" -eq 02 ]
then
## run integrity before
elif [ "$Nomral_Day" -eq 26 ] && [ "$DAY_Word" != "Friday" ] && [ "$MONTH" -eq 02 ]
then
## run integrity before
fi
答案1
不能省略then
和之间的命令elif
。您必须包含一个命令。
添加命令true
,您的脚本应该可以工作。