EN
Bash - iterate through array values
3 points
This article will show you how to iterate through array values in Bash.
Quick solution:
xxxxxxxxxx
1
2
3
array=(Tom Kate Mary)
4
5
for i in "${array[@]}"
6
do
7
echo $i
8
done
Example output:
xxxxxxxxxx
1
Tom
2
Kate
3
Mery
It is possible to use an alternative approach to access array items - it is ${array[*]}
.
xxxxxxxxxx
1
2
3
array=(Tom Kate Mary)
4
5
for i in "${array[*]}"
6
do
7
echo $i
8
done
Example output:
xxxxxxxxxx
1
Tom
2
Kate
3
Mery