最近剛開始學習linux shell語言
看的是鳥哥的私房菜,裏面有講到執行shell腳本有兩種方法:
1. 設置執行屬性: chmod 755 file
執行(如果已經在當前目錄) : ./file
2. 使用: sh file 執行
.但是在vmware裏裝的ubuntu 11.10卻無法執行
#!/bin/bash
declare -i s
for (( i = 1; i <= 100;i = i+1 ))
do
s=s+i
done
echo "The count is ==> $s"
使用第二種方法執行時出現 :
test04_for.sh: 1: declare: not found
test04_for.sh: 3: Syntax error: Bad for loop variable
百度了下網上,解決方法:
在終端中輸入:
sudo dpkg-reconfigure dash
然後出現的界面中選擇 NO
然後就能正確運行了。