我似乎无法弄清楚以下if
语句中涉及elif
和then
的问题。请注意,printf
仍在开发中,我还没有能够在语句中测试它,所以很可能是错误的。
我收到的错误信息是:
./timezone_string.sh: line 14: syntax error near unexpected token `then'
./timezone_string.sh: line 14: `then'
而且陈述就是这样。
if [ "$seconds" -eq 0 ];then
$timezone_string="Z"
elif[ "$seconds" -gt 0 ]
then
$timezone_string=`printf "%02d:%02d" $seconds/3600 ($seconds/60)%60`
else
echo "Unknown parameter"
fi
if
和elif
语句中需要then
,而在else
中不需要,在一般情况下也是如此。 - user4104817