Loop Through Arrays in Bash
1 min read

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