Break and continue of the "shell" Linux shell

Source: Internet
Author: User

Break and continue can all be used in the loop, but the two functions are a bit different, for example, break is jumping out of the loop, while continue is jumping out of the loop and going on to the next loop, we'll show the difference between the two in the following example.

**

Example: Print the number 1-10 if i>8 you exit the loop.

#!/bin/bash -for i in `seq 10`do        [ $i -gt 8 ] && break || echo $idone

Execution Result:

Example 2: Loop 1-10, except 8, the remaining numbers are displayed.

[[email protected] scripts]# cat break.sh #!/bin/bash -for i in `seq 10`do        

Summary: Break is jumping out of all loops, and continue is skipping a loop.

All rights reserved: Arppinging

Break and continue of the "shell" Linux shell

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.