1 # usage: reverse arrayname
8 # make r a copy of the array whose name is passed as an arg
9 eval R=\( \"\$\{$1\[@\]\}\" \)
14 for ((i=0; i < rlen/2; i++ ))
21 # and assign R back to array whose name is passed as an arg
22 eval $1=\( \"\$\{R\[@\]\}\" \)
32 # unset last element of A
37 # ashift -- like shift, but for arrays
47 *) echo "$FUNCNAME: usage: $FUNCNAME array [count]" >&2
51 # make r a copy of the array whose name is passed as an arg
52 eval R=\( \"\$\{$1\[@\]\}\" \)
57 # and assign R back to array whose name is passed as an arg
58 eval $1=\( \"\$\{R\[@\]\}\" \)
70 # Sort the members of the array whose name is passed as the first non-option
71 # arg. If -u is the first arg, remove duplicate array members.
82 echo "array_sort: argument expected" >&2
86 # make r a copy of the array whose name is passed as an arg
87 eval R=\( \"\$\{$1\[@\]\}\" \)
90 R=( $( printf "%s\n" "${A[@]}" | sort $u) )
92 # and assign R back to array whose name is passed as an arg
93 eval $1=\( \"\$\{R\[@\]\}\" \)
97 A=(3 1 4 1 5 9 2 6 5 3 2)
101 A=(3 1 4 1 5 9 2 6 5 3 2)