小弟最近才開使用shell script (bash)
但發現了一個怪問題
很多指令再terminal 直營都沒問題
但是寫在script 裡面執行就會出錯
譬如 我想定義一個string array
如果在terminal 直接輸入
declare -a arr=('001' '002' '003')
就沒問題
但如果存成檔名test1.sh 的script 再執行
就會出現以下錯誤
test1.sh: 1: test1.sh: Syntax error: "(" unexpected
請問友人知道怎麼解決嗎?
--
但發現了一個怪問題
很多指令再terminal 直營都沒問題
但是寫在script 裡面執行就會出錯
譬如 我想定義一個string array
如果在terminal 直接輸入
declare -a arr=('001' '002' '003')
就沒問題
但如果存成檔名test1.sh 的script 再執行
就會出現以下錯誤
test1.sh: 1: test1.sh: Syntax error: "(" unexpected
請問友人知道怎麼解決嗎?
--
All Comments