01 / 08
When the number is not settled
for went round a row of things.
for F in *.txt; do ... done as many as there are filesfor N in $(seq 1 5); do ... done five timesEither way, the number of goes is settled before you start.
But what about times like these?
read a line at a time until the file runs outwait until the free space drops below 90%You do not know how many. For these you use while.
while condition; do the doingdoneYou read it as "repeat while the condition holds".
for a row of things, in orderwhile while a condition lasts, on and onToday there is one more important tool.
while read L; do echo "[$L]"done < table.txtread is the command that reads one line. Combine it with while and you can handle lines one at a time, properly.
This, in fact, is something for cannot do cleanly. You will see why later.