Repeating
Repeating: For Every File: for Loops, Line by Line: while read, Stopping Early: break, continue and Counters.
Updated
- For Every File: for Loops (Apprentice): A for loop runs the same commands once for every word, number or file in a list, so renaming 12 files or 200 takes one line, with ${f%.tmp} cutting the old ending off each name.
- Line by Line: while read (Journeyman): while IFS= read -r line reads a file one whole line at a time, spaces and backslashes kept, and while and until repeat commands for as long as a condition is true, or until it becomes true.
- Stopping Early: break, continue and Counters (Apprentice): A counter or running total is a variable a loop adds to each time round with $(( )); continue skips the rest of one pass and goes on with the next item, and break leaves the loop early.