#!/bin/bash
echo "Example loop."
for i in $(echo "The bear went over the mountain"); do
echo "$i";
done
exit 0;
Output should be:
The
bear
went
over
the
mountains
In that ine with the for in it. The order is like this 1.) "The bear went over.." is (printed without the quotes). So, the for line is basically like:
for i in the bear went over the mountain
each time through the loop, i is assigned to each of the whitespace separated tokens
so, the commands the for loop essentially runs is:
echo the
echo bear
echo went
echo over
echo the
echo mountains