Loop Through Arrays in Bash

How to loop through arrays in Bash


Looping through arrays in Bash

Create an array with the following syntax.

packages=(curl git wget vim)

You can simply loop through it with a for-loop.

for program in "${apt_programs[@]}"; do
    sudo apt-get install ${program}
done