Languages
[Edit]
EN

Bash - iterate through array values

3 points
Created by:
Dirask Admin - Marvin
1820

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

Bash

Bash - iterate through array values
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join