]>
Commit | Line | Data |
---|---|---|
95732b49 JA |
1 | x=(one two) |
2 | echo ${x[@]:1} | |
3 | echo ${x[@]:0:1} | |
4 | ||
5 | x=(one) | |
6 | echo ${x[0]:1} | |
7 | echo ${x[0]:0} | |
8 | echo ${x[@]:1} | |
9 | echo ${x[@]:0} | |
10 | ||
11 | echo ${x[@]: -1} | |
12 | echo ${x[@]: ${#x[@]}-1} | |
13 | ||
14 | x=(0 1 2 3 4 5 6 7 8 9) | |
15 | echo ${x[@]:1} | |
16 | ||
17 | echo ${x[@]: -1} | |
18 | echo ${x[@]: ${#x[@]}-1} | |
19 | ||
20 | set -- ${x[@]} | |
21 | ||
22 | echo $1 | |
23 | echo ${@: -1} | |
24 | echo ${@: $#-1} | |
25 | ||
26 | a=0123456789 | |
27 | ||
28 | echo ${a:1} | |
29 | echo ${a: -1} | |
30 | echo ${a: ${#a}-1} | |
3185942a JA |
31 | |
32 | # problem with bash through 3.2.33 | |
33 | oIFS="$IFS" | |
34 | IFS=$'\n' | |
35 | a=(A B C D) | |
36 | b=("${a[@]}") | |
37 | echo "${#b[@]}", "${b[@]}" # 4, A B C D -- OK | |
38 | b=("${a[@]:2}") | |
39 | echo "${#b[@]}", "${b[@]}" # 1, C D -- bug, should be 2, C D | |
40 | IFS="$oIFS" |