Linux Reader
Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows

Pew Pew madafakas!

Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows

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

FREE DOWNLOADVer 4.13, WinUpgrade to PROFrom $29.95

Please rate this article.
51 reviews