Get the App
SLTechnology News&Howtos  ›  Servers  › 

Use the break command of linux to end the for while or until loop

Shulou Source: shulou.com Published: 2022-06-02 12:44:50 10月02日 Update

Do not know how to use linux's break command to end a for while or until loop? In fact, it is not difficult to solve this problem. Let the editor take you to learn how to solve it. I hope you will gain a lot after reading this article.

The break command is used to end the for,while or until loop, and you can specify how many layers of the loop to exit.

Syntax format: break [parameters]

Common parameters:

Reference exampl

The default value of the optional parameter n for break is 1:

For ((jumb3witj > 0positanjmur-)); do for ((item3bomi > 0polii -)); do if ((juniors 2)); then break fi printf "% s% s\ n" ${I} ${j} done done # output result 3 3 2 3 1 3

When n is 2: exit the two-tier loop and end:

For ((item3teri > 0poliimuri -)); do for ((jumb3terj > 0positjmuri -)); do if ((jackfruit 2)) Then break 2 fi printf "% s% s\ n" ${I} ${j} done done # output result 3 3 Thank you for reading this article carefully. I hope it is helpful for the editor to share and use linux's break command to end the for while or until cycle. At the same time, I also hope you can support us, pay attention to the industry information channel, find the problem, and the detailed solution is waiting for you to learn!

Tags: Loops commands parameters articles results questions learning output content at the same time commonly used methods formats examples tape industry grammar information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Docker Huawei MariaDB macOS