RosettaCodeData/Task/Arrays/UNIX-Shell/arrays-4.sh

6 lines
263 B
Bash

x=${#alist[*]} # start with the number of items in the array
while [[ $x > 0 ]]; do # while there are items left
: $((x--)) # decrement first, because indexing is zero-based
echo "Item $x = ${alist[$x]}" # show the current item
done