Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the break command in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to use the break command in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Common Linux commands-break commands are mainly used to end for,while or until loops

Break ends the for,while or until loop.

Summary break [n] the main purpose is to end the for,while or until loop, and several layers of loops can be specified to exit.

Parameter n (optional): an integer greater than or equal to 1 that specifies how many layers of loop to exit.

The return value returns success unless n is less than 1.

The default value of the optional parameter n for example # break is 1. # continue execution from the outer for loop. For ((item3safi > 0positanimuri -); do for ((juni3Shij > 0positjmura -)); do if ((jackfruit 2)); then # instead of break 1 results the same 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 ((item3persi > 0positsu -)); do for ((juni3witj > 0positjmure -)); do if ((jacks 2)); then break 2 fi printf "% s% s\ n" ${I} ${j} done done # output result 3 3 Note this command is a bash built-in command, for related help, please see the help command.

Thank you for reading! This is the end of this article on "how to use break commands in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report