如何在bash for循环中内联一个字符串数组?这有效:
array=(one two) for i in ${array[*]};do echo $i; done
但我想消除额外的局部变量.我尝试了许多似乎合理的变体,例如:
for i in ${("one" "two")[*]};do echo $i; done
要么
for i in ${"one" "two"};do echo $i; done
在每种情况下,它对待one
和two
作为命令:(
你尝试过:
for i in "one" "two"; do echo "$i"; done