In this final chapter on flow control, we will look at another of the shell’s looping constructs. The for loop differs from the while and until loops in that it provides a means of processing sequences during a loop. This turns out to be very useful when programming. Accordingly, the for loop is a very popular construct in
A for loop is implemented, naturally enough, with the
for command. In modern versions of
for is available in two forms.
for command’s syntax is as follows:
in words]; do
variable is the name of a variable that will increment during the execution of the loop,
words is an optional list of items ...