bash – iterating over a string array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#declare -a myArrayList=(
myArrayList=(
# NEW ENTRIES BELOW THIS LINE
Judy
Bob
"Adam Smith"
Bonnie
# NEW ENTRIES ABOVE THIS LINE
)

## IF YOU HAVE SPACES IN THE ITEMS - THE ITEM NEEDS TO BE QUOTED

for item in "${myArrayList[@]}"; do
  echo $item
done