While Loops

Difficulty: Intermediate
Duration: 5 minutes and 42 seconds
Students: 883
Rating: 3.7/5

A while loop is a loop that repeats a series of commands for as long as a given condition is true. In this Lesson, you'll be introduced to while loops.

Learning Objectives

  • Learn how and when to create infinite while loops.
  • Understand the different ways to control the number of times a loop is performed.
  • Learn how to limit the number of loops, end a loop based on user input, and end a loop based on the exit status of a given command.
  • Learn how to read a file one line at a time.
  • Understand how to use the break and continue statements to selectively operate on items in a loop.

Intended Audience

This Lesson is intended for anyone looking to learn more about bash scripting and shell programming.

Prerequisites

To get the most out of this Lesson, you should have some basic knowledge of the command line, but it's not essential.

Covered Topics