The general format of the for loop is:
for variable_name in list do command1 command . . . done
The for loop processes all the information once for each value contained in list. To access each value in list use variable_name. The commands can be any valid shell command or statement. Variable_name can be any word you want.
The use of in list is optional; if you do not include it, the for loop uses the positional parameters from the command line.
The in list can contain substitution, strings and filenames. Let’s look at some examples.
This loop simply echoes out the list, which is ‘1 2 3 4 5’. To access each variable the variable_name loop is used.
$ pg for_i #!/bin/sh # for_i for loop in 12345 do ...