From the course: Learning Bash Scripting
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Working with "while" and "until" loops - Bash Tutorial
From the course: Learning Bash Scripting
Working with "while" and "until" loops
- [Instructor] Loops are control structures that run a specific piece of code over and over until the loop is caused to end. There's two kinds of loops that are dependent on conditions, called while loops and until loops. The while loop runs for the duration of time when its condition is true and stops when that condition becomes false. The until loop runs for the duration of time when its condition is false and stops when that condition becomes true. The difference is fairly subtle, but depending on what you want your script to do, one may be more suitable than the other. Both types of loops start with the appropriate keyword and the condition to use to determine whether the loop should keep running. That's followed by do and the code to loop through. And then the construct ends with done. Let's take a look at the while loop with a simple example that counts up to 10. I'll create an integer variable with a value of 0.…
Contents
-
-
-
-
-
Conditional statements with the "if" keyword4m 17s
-
(Locked)
Working with "while" and "until" loops3m 57s
-
(Locked)
Introducing "for" loops4m 22s
-
(Locked)
Selecting behavior using "case"2m 11s
-
(Locked)
Using functions6m 17s
-
(Locked)
Reading and writing text files3m 25s
-
(Locked)
Challenge: Build a script using control structures33s
-
(Locked)
Solution: Build a script using control structures1m 18s
-
-
-
-