Few command-line tools have implicit looping and conditionals built into them. Often, tasks will only operate on each line of an input stream and then terminate. The shell provides just enough control flow and conditionals to solve many complex problems, making up for any deficiencies that command-line tools have for operating on data.
The almighty for loop is a common loop idiom, however bash's for loop might feel a little unfamiliar to users of more traditional languages. The for loop allows you to iterate over a list of words, and assign each one to a variable for processing. For example, (pun intended):
Often, we want a more traditional range of numbers in our for loops. The POSIX method of generating a number range is to use the seq command, as in seq -- $(seq 1 1 5), which will generate numbers from 1 (the first argument) to 5...