Venga now - the commands I always forget
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
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment