2016-12-15 7 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] 
関連する問題