Originally posted by jbsnake
yes...you can sing that to the tune of "i love a parade"
anyway
i'm here to simplify arrays for everyone
all an array is, is a chest of drawers
each drawer is a variable
the bottom (or top) drawer is 0
want an example?
no prob
Code:
#!/bin/bash
# i want a chest of drawers (not sure how many drawers i want yet)
declare -a chest;
# drawer 1 has socks in it
chest[0]="socks"
# drawer 2 has shirts in it
chest[1]="shirts"
# drawer 3 has pants in it
chest[2]="pants"
# we get the total number of filled drawers in the chest
numberofdrawers=${#chest[*]}
# make a loop with what we know
# increasing by one each time it loops
for (( drawernumber=0; $drawernumber != $numberofdrawers; drawernumber++ ))
do
echo "${chest[$drawernumber]} are in the number $((drawernumber+1)) drawer...with actual drawer number $drawernumber"
done
if you run that i think you'll have a good understanding of arrays
