Venga now - the commands I always forget
Showing posts with label
array
.
Show all posts
Showing posts with label
array
.
Show all posts
Wednesday, 14 November 2012
How to iterate through an array in bash? one liner
$ export MYARRAY=("one" "two" "three" "four")
$ for i in ${MYARRAY[@]}; do echo $i;done
one
two
three
four
and to reverse the loop
$ for (( idx=${#MYARRAY[@]}-1 ; idx>=0 ; idx-- )) ; do echo ${MYARRAY[idx]} ; done
Older Posts
Home
Subscribe to:
Posts (Atom)