EN
Bash - iterate through array values
3
points
This article will show you how to iterate through array values in Bash.
Quick solution:
#!/bin/bash
array=(Tom Kate Mary)
for i in "${array[@]}"
do
echo $i
done
Example output:
Tom
Kate
Mery
Alternative solution
It is possible to use an alternative approach to access array items - it is ${array[*]}
.
#!/bin/bash
array=(Tom Kate Mary)
for i in "${array[*]}"
do
echo $i
done
Example output:
Tom
Kate
Mery