2016-12-15 23 views

回答

3

您可以運行它像這樣:

arr=("option1" "option with space" "option3") 

executable "${arr[@]}" 
1

只需通過數組的內容爲可執行文件,

<executable> "${ARR[@]}" 

雙擊引用數組的內容是很重要的位置,並失去它會讓選項留有空格。

用一個例子的圖: -

dudeOnMac:~$ touch file 
dudeOnMac:~$ touch "file with spaces" 
dudeOnMac:~$ ls 
file   file with spaces 
dudeOnMac:~$ touch "[email protected]" 
dudeOnMac:~$ ls 
file   file with spaces [email protected] 
dudeOnMac:~$ fileList=("file" "file with spaces" "[email protected]") 
dudeOnMac:~$ ls "${fileList[@]}" 
file   file with spaces [email protected] 
dudeOnMac:~$ ls -1tr "${fileList[@]}" 
file 
file with spaces 
[email protected] 
相關問題