45.17 Making a for Loop with Multiple VariablesThe normal Bourne shell for loop (44.16 ) lets you take a list of items, store the items one by one in a shell variable, and loop through a set of commands once for each item: for file in prog1 prog2 prog3 do ...process $file done I wanted a for loop that stores several different shell variables and makes one pass through the loop for each set of variables (instead of one pass for each item , as a regular for loop does). This loop does the job:
If you have any command-line arguments and still need them, store them in another variable before you do that. Or, you can make the loop this way:
This script uses the shell's
eval
(8.10
)
command to re-scan the contents of the
bunch
variable and store it in separate variables.
Notice the single quotes like - |
|