關於shell script 一個奇怪的問題 - Linux

By Ida
at 2013-07-02T14:35
at 2013-07-02T14:35
Table of Contents
小弟最近才開使用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
請問友人知道怎麼解決嗎?
--
Tags:
Linux
All Comments

By Caitlin
at 2013-07-04T14:09
at 2013-07-04T14:09

By Leila
at 2013-07-06T17:42
at 2013-07-06T17:42

By Queena
at 2013-07-08T11:35
at 2013-07-08T11:35

By Daniel
at 2013-07-10T01:43
at 2013-07-10T01:43

By Daph Bay
at 2013-07-12T13:48
at 2013-07-12T13:48

By Emily
at 2013-07-14T13:45
at 2013-07-14T13:45

By Rosalind
at 2013-07-15T01:45
at 2013-07-15T01:45

By Enid
at 2013-07-18T03:16
at 2013-07-18T03:16

By Quintina
at 2013-07-20T05:14
at 2013-07-20T05:14

By Blanche
at 2013-07-23T19:05
at 2013-07-23T19:05

By Rachel
at 2013-07-28T09:43
at 2013-07-28T09:43

By Ingrid
at 2013-07-31T18:54
at 2013-07-31T18:54

By Hedwig
at 2013-08-02T21:34
at 2013-08-02T21:34

By Tristan Cohan
at 2013-08-02T23:31
at 2013-08-02T23:31

By Franklin
at 2013-08-03T22:38
at 2013-08-03T22:38

By Isla
at 2013-08-08T05:44
at 2013-08-08T05:44

By Valerie
at 2013-08-12T20:01
at 2013-08-12T20:01

By Audriana
at 2013-08-16T12:10
at 2013-08-16T12:10

By Wallis
at 2013-08-21T08:57
at 2013-08-21T08:57

By Dorothy
at 2013-08-22T10:20
at 2013-08-22T10:20

By Callum
at 2013-08-22T17:18
at 2013-08-22T17:18

By Heather
at 2013-08-25T07:32
at 2013-08-25T07:32

By Oliver
at 2013-08-26T20:54
at 2013-08-26T20:54

By Isla
at 2013-08-27T05:31
at 2013-08-27T05:31
Related Posts
ssh連不上VMware的linux(bridged network)

By Brianna
at 2013-07-01T17:30
at 2013-07-01T17:30
ssh GUI的問題

By Enid
at 2013-07-01T13:57
at 2013-07-01T13:57
ubuntu 桌面將轉用Qt/QML

By Eden
at 2013-07-01T13:57
at 2013-07-01T13:57
OpenCV2.4.5在ubuntu13.04下安裝

By Yedda
at 2013-07-01T13:33
at 2013-07-01T13:33
HackingThursday 固定聚會 (2013-07-04)

By Ingrid
at 2013-07-01T12:02
at 2013-07-01T12:02