Chapter 9. Repetitive tasks

Table of Contents

1. The for loop
1.1. How does it work?
1.2. Examples
2. The while loop
2.1. What is it?
2.2. Examples
3. The until loop
3.1. What is it?
3.2. Example
4. I/O redirection and loops
4.1. Input redirection
4.2. Output redirection
5. Break and continue
5.1. The break built-in
5.2. The continue built-in
5.3. Examples
6. Making menus with the select built-in
6.1. General
6.2. Submenus
7. The shift built-in
7.1. What does it do?
7.2. Examples
8. Summary
9. Exercises

Abstract

Upon completion of this chapter, you will be able to

  • Use for, while and until loops, and decide which loop fits which occasion.

  • Use the break and continue Bash built-ins.

  • Write scripts using the select statement.

  • Write scripts that take a variable number of arguments.