Summary

9.8. Summary

In this chapter, we discussed how repetitive commands can be incorporated in loop constructs. Most common loops are built using the for, while or until statements, or a combination of these commands. The for loop executes a task a defined number of times. If you don't know how many times a command should execute, use either until or while to specify when the loop should end.

Loops can be interrupted or reiterated using the break and continue statements.

A file can be used as input for a loop using the input redirection operator, loops can also read output from commands that is fed into the loop using a pipe.

The select construct is used for printing menus in interactive scripts. Looping through the command line arguments to a script can be done using the shift statement.


16 visits (1 today, 13 this week, 16 this month, 16 this year)
Uptime: 12:55:59 up 5 days, 17:20, 2 users, load average: 0.01, 0.03, 0.00
2600:1f28:365:80b0:1b26:d2f4:3509:f38b GET from server z.larrymurakami.com

Thursday, April 16, 2026 @ 12:55:59 PM
z.ServerAdmin@lamurakami.com