Shell until loop

Source: Internet
Author: User

The Until loop executes a series of commands until the condition is true. The Until loop and the while loop are just the opposite of the processing mode. The general while loop is better than the until loop, but at some point it is only rare that the until loop is more useful.

The Until loop format is:

Until Commanddo   Statement (s) to being executed until command is Truedone

The command is usually a conditional expression, and if the return value is false, the statement in the loop body continues to execute, otherwise it jumps out of the loop.

For example, use the until command to output a number from 0 to 9:

    1. #!/bin/bash
    2. A=0
    3. Until [ ! $a -lt ]
    4. Do
    5. echo $a
    6. a= ' expr $a + 1 '
    7. Done

Operation Result:

0123456789

Shell until loop

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.