Learn to create a program loop in a bash shell script at the Linux command line.
Linux bash until loop with examples (3:40)
Videos can also be accessed from the YouTube Playlist.
Our ninety-ninth word, or command (keyword) to memorize is
until from our category
until allows you to create a program
loop (like in a bash shell script).
Recall from videos (tutorials) #96 and #98 on
for we explored keywords used to
create loops, and now we'll see a third example.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
until command (keyword) has
no traditional options and no arguments as it is
technically a keyword, and it too uses
done syntax, like we've seen before.
Unlike most commands, help is not available with double-dash
until is a shell built-in
covered in the
So why is
until an important command (keyword)?
until is very similar to
while, and it gives you another option
for simplifying loop logic.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go. Let's review the 3 keywords in this group.
All, as you can see, are keywords.
Next, let's create a loop using the same
while statement at the command line
as we did in video (tutorial) #96. Start by setting the count equals
Then the logic with
while count is less than or equal to
8, print the count, then add one to the count, and head back up until the
exit code from the
while is not
true, thus it repeats.
And then last, let's compare. We will get that same result with
until. Except here, the exit status
is false until it gets to greater than 8, so false 8 times, then the
count is above 8 and it breaks out of the loop and hits the
Very good (remember we will return to our final script in the next tutorial).
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
(keyword). So when do you use
while? It can be personal
preference, but with experience one or the other will allow you to
simplify the code, which really is the goal.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the
until command (keyword).
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
If you learned something here, please consider joining our YouTube Channel. Subscribe here.
forstatement, hit Back.
foldcommand. Click Next.