2016-04-04 65 views
0
我有執行以下bash腳本麻煩

bash腳本if和while條件

#!/bin/bash 
response=" " 
while ["$response" != "q"]; do 
echo -n "Please enter a response"; read response 
done 

ALSO

!/bin/bash 
response="x" 

if ["$response" = "x"] 
then 
echo "the value is x" 
fi 

還有什麼可能的錯誤是什麼?

回答

0

你的while和if語句間隔錯誤。

while [ "$response" != "q" ]; do etc 

您需要括號和雙引號之間的空格。

+0

謝謝你好先生!這是我的最後一招,我花了大約2個小時試圖找出錯誤。 – MahaRaja