The Shell Scripting Guide for the Uncoordinated

So, you think you can handle the wild world of Bash arrays? Think again. Or do you?

Bash arrays are not just for the faint of heart, but for the bravest of souls.

Here's how to map your Bash array like a pro:

Map like the Wind

Use the map function to iterate over each element in the array, like a gentle breeze through the desert.

Example:

for i in {1..5}; do echo $i; done

Or, for the more adventurous:

for i in {1..5}; do echo $i; done | grep something

Or, for the truly bold:

for i in {1..5}; do do_something_crazy $i; done

Where do_something_crazy is a function that makes the user question their life choices.

Want more examples?

Example 1 | Example 2 | Example 3

Or, if you're feeling particularly extra, try:

Example 4 | Example 5