我使用Cygwin來運行腳本,當我使用if else條件時出現語法錯誤。 你能告訴我我的腳本有什麼問題嗎?語法錯誤Cygwin如果否則條件
./test.sh:第10行:附近意外的標記
else' ./test.sh: line 10:
別的語法錯誤'
#!/bin/bash
date
schema=''
table='JJJJ'
first=${table:0:1}
echo $first
if [$first == 'J']
echo 'SUCCESS';
else
echo 'error';
fi
感謝
你錯過了'then'。 '['和'$ first'之間的空格。我可以建議使用http://www.shellcheck.net嗎? – Biffen