Array in for loop

Using Array in a FOR loop

Array in for loop

Given the array definition:

names=( Jennifer Tonya Anna Sadie )

The following expression evaluates into all values of the array:

${names[@]}

and can be used anywhere a variable or string can be used.

A simple for loop can iterate through this array one value at a time:

for name in ${names[@]}
do
   echo $name
done

Also note you can do

number=(1..200)

To create an array with numbers from 1 to 200.


Browse Space

- Pages
- News
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

 

Other Features

Add Content

- Add Comment