Using arrays

Arrays are a special type of containers that hold multiple values at the same time.

For instance, the rainbow is made of 7 colors. We can create an array variable that holds all the colors of the rainbow.

Create a new file named arr and add the following lines of code to the file.

#!/bin/bash

rainbows=(red orange yellow green blue indigo violet)

echo "${rainbows[@]}"

Make it this file executable and run the script.

You should see the following output:

red orange yellow green blue indigo violet
Last change: 2025-09-03, commit: 6636d47