While Loops

Intermediate
6m
736
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.

About the Author
Avatar
Jason Cannon, opens in a new tab
Founder, Linux Training Academy
Students
24,620
Courses
61
Learning paths
19

Jason is the founder of the Linux Training Academy as well as the author of "Linux for Beginners" and "Command Line Kung Fu." He has over 20 years of professional Linux experience, having worked for industry leaders such as Hewlett-Packard, Xerox, UPS, FireEye, and Amazon.com. Nothing gives him more satisfaction than knowing he has helped thousands of IT professionals level up their careers through his many books and courses.

Covered Topics