for Loop
noun
say it: “FOR LOOP” /ˈfɔr ˈlup/
A loop that repeats the same commands once for each item in a list, such as every file in a folder.
What is a for loop in bash?
A for loop runs the same commands once for every item in a list, with a variable holding the item each time. The list can be words you type, numbers from braces such as {1..10}, or files from a wildcard, which makes renaming hundreds of files one short loop.
for f in telemetry/*.tmp; do
mv "$f" "${f%.tmp}.log"
done
In a sentence
- “One for loop renamed all thirty telemetry files.”
- “The for loop counted down from 10 to 1 before printing Liftoff.”
Level: Apprentice · More Unix terms at this level
Updated