What is a bash UNTIL loop?
Here you will find out:
- what bash UNTIL loop is
- what the difference between a WHILE loop and an UNTIL loop is
- how to use an UNTIL loop in a shell script
- when DiskInternals can help you
Are you ready? Let's read!
About bash UNTIL loop
A bash UNTIL loop is similar to a bash WHILE loop. However, the UNTIL loop is used to run a series of commands based on Boolean-like outcomes; that is, an expression has to return “True” or “False” before your loop commands will execute. But in the case of a bash UNTIL loop, the commands will only be executed if the expression returns “True”. If an expression returns “False”, a bash UNTIL loop will repeat the same set of commands until it returns "True".
The syntax of a bash UNTIL loop
Here’s the syntax of an UNTIL loop. It looks similar to a bash WHILE loop, but the functionality differs:
Single expression syntax
Multiple expressions syntax
Notice the dual brackets in the multiple expression syntax. You should use double brackets for multiple expressions and a single bracket for single expressions.
Things to note:
- A bash UNTIL loop will check for expressions/conditions before running commands.
- Commands will run only if the expression(s) returns “False”.
- The loop will be terminated if the expression returns “True”.
- After termination, program control is passed to the command written below “Done”.
If you want to understand the actual difference between a WHILE and an UNTIL loop, read below.
The difference between a WHILE loop and an UNTIL loop
An UNTIL loop will only run your commands if the defined expression returns a non-zero code. In contrast, a WHILE loop will run your commands when the expression returns a zero status.
Using an UNTIL loop in a shell script
In order to explain the bash UNTIL loop for easy understanding, here are some basic, practical examples.
Single expression:
Multiple expressions:
If you need to get files from Linux in Windows
Getting files from your Linux partitions in Windows is not feasible unless you use a third-party assistant. DiskInternals Linux Reader is an advanced software utility that allows you to access and open Linux files while operating in Windows. It is a smart software application that is packed with handy features for your needs. DiskInternals Linux Reader features the best interface you can expect. Most interestingly, this software supports all types of Linux partitions. Getting your Linux files takes just three steps when you use DiskInternals Linux Reader, and it is capable of reading media files, as well as documents. DiskInternals Linux Reader is arguably the best of its kind and the easiest to use, thanks to its distinctive interface.
Related articles
- About a bash date command
- How to Access Linux Ext2 or Ext3 on Windows
- How to Access Ext4 from Windows
- How to Mount Ext4 on Windows for Free
- Mount Linux Drive on Windows for Free
- Bash Script: All You Need to Know
- An Algorithm: How to Create Bash While Loop
- Linux Shell: What You Need to Know at First
- 5 Basic Shell Script Examples for Your First Script
- Bash: How to Check if the File Does Not Exist
- Bash Time Command on Linux
- How to use bash get script directory in Linux
- How to Check Bash String Equality
- How to Use Linux Wait Command
- Bash: How to Loop Through Files in Directory
- 20 Examples of Bash Find Command
- Bash Cat Command in Examples
- Bash Script SSH: How to Use It
- Bash: A Script For User Input
- Linux ZSH: the basic you need to know
- Basic of Grep in Linux Shell Script
- Shell Script Cut: Basic You Need to Know
- Bash: How to Check if String Not Empty in Linux
- Bash: how to split strings in Linux
- Linux: Sudo in Bash Scripts
- Hello World Script in Bash
- A Linux bin/bash Shell
- Linux: New Line in Shell Script
- Linux: Bash String Ends With
- Linux: Bash Printf Examples
- Linux: Bash First Line
- Linux: $0 in a Shell Script
- Linux: A Bash Startup Script
- Linux: Write a Shell Script
- Shell Script: Replace String in File
- A crontab service shell script
- Bash and sh: is there any difference
- A Bash Dirname Command
- Linux: A Bash Source Command
- A Bash to Loop through Lines in File
- Linux: A Bash Linter
- A Bash Nested Loop
- A Bash Test Command
- Use a Shell Script to Send an Email
- A Bash Status of Last Command
- Linux: A Bash Basename Command
- Using Bash to Write to a File
- About Bash Language
- Bash for Loop in One Line
- AWK in a Bash Script
- Learn about useful bash scripts
- Learn about systemd startup script
- About chaining bash commands
- Learn about a bash error code
- Using a bash tee command
- About a bash export command
- Learn about a bash wait command
- Arch Linux install script
- About advanced bash scripting
- To run a shell script in Dockerfile
- Learn about C shell script
- Learn about Korn shell scripting
- Using /usr/bin/env command
- Whether bash waits for command to finish
- Using bash if 0
- Using && in an IF statement in bash
- If you want to run shell script in background
- The disk you inserted was not readable by this computer error
- Learn about SFTP in bash scripting
- Learn to run Perl script in Linux
- Examples of using the Expect
- Copy command in shell scripts
- Shell script usage
- Install Oracle Database
- Here is everything you need to know about Bash for Windows
- Guide in Pictures
- How to Use Shell Script Sleep Command
- A Bash Multiline Command




