I have an indexed bash array and I'd like to use an expression like "${a[@]}" except I want it to not include a[0]. The best that I can think of is this:
我有一个索引的bash数组,我想使用像“$ {a [@]}”这样的表达式,除非我希望它不包含[0]。我能想到的最好的是:
j=0
for i in "${a[@]}"
do
b[j]=${a[++j]}
done
and then use "${b[@]}". Is there a better way?
然后使用“$ {b [@]}”。有没有更好的办法?
1 个解决方案
#1
33
$ a=(1 2 3)
$ echo "${a[@]:1}"
2 3
#1
33
$ a=(1 2 3)
$ echo "${a[@]:1}"
2 3