Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
只是一个简单的问题。
我有一个数组:
array=("1 2 3" "4 5 6")
如果我做:
echo ${array[0]} echo ${array[1]}
将显示 1 2 3 或 4 5 6。
但是,如果我这样做:
for iter in ${array[@]} do echo $iter done
显示的值不符合我的预期....谁能给我正确的使用方法?
报价是您需要的:
for iter in "${array[@]}"; do echo "$iter" done