当前位置:网站首页>Shell script explanation (IV) -- while loop and until loop of loop statements (additional examples and analysis)
Shell script explanation (IV) -- while loop and until loop of loop statements (additional examples and analysis)
2022-06-22 19:26:00 【Be the best Messi】
One 、while loop
1、 Loop structure
Test a condition repeatedly , As long as the conditions are met , And then it goes back and forth , If the condition does not hold, exit the loop ( and until The cycle is reversed )
Two 、until loop
1、 Loop structure
Test a condition repeatedly , As long as the conditions are not established , And then it goes back and forth , If the condition holds, exit the cycle

Example (until loop )
Calculate from 1 To 100 The sum of all integers


while loop
①、 Batch add users
- The user name is stu start , Number in order
- Add all together 20 Users , namely stu1、stu2、stu3…stu20
- The initial password is set to 123456


②、 Guess the number game
- Through the variable RANDOM get 0-999 Between random integers
- Prompt the user to guess , And record the number of times
- If the guessed number is too large or too small, the user will be prompted , Guess right to exit the loop


③、 Calculate from 1 To 100 The sum of all integers

④、 Filter out from 1 To 100 Odd even number of all integers


⑤、 Prompt the user to enter a value less than 100 The integer of , And calculate from 1 The sum of all integers between and


⑥、 Seek from 1 To 100 The even sum of all integers 、 Odd and


⑦、 Detect whether the specified range hosts communicate , And will communicate with the host ip output to a file host_ip in

Catalog
Calculate from 1 To 100 The sum of all integers
③、 Calculate from 1 To 100 The sum of all integers
④、 Filter out from 1 To 100 Odd even number of all integers
⑥、 Seek from 1 To 100 The even sum of all integers 、 Odd and
边栏推荐
- Zynq UltraScale + RFSoC ZCU111 RF时钟树学习 1
- Golang implements redis (10): local atomic transactions
- Shell编程规范与变量
- 贪心之分配问题(1)
- Notes on Combinatorics (V) chains in distributive lattice
- 2022 G2 power plant boiler stoker question bank and online simulation examination
- 使能伙伴,春节重大保障“不停歇”
- 2022重庆幼教产业展览会|高科技玩具益智解压玩具博览会
- Is flush easy to open an account? Is it safe to open a mobile account?
- 新人报道的笔记
猜你喜欢
随机推荐
SystemVerilog (12) - $unit declaration space
数字赋能机械制造业,供应链协同管理系统解决方案助力企业供应链再升级
Custom database connection pool class: requirement: enclose the collection class of a collection object
Dynamically changing the style of label elements in a loop
一些技术想法:
Robotframework installation tutorial
org. apache. ibatis. binding. BindingException: Invalid bound statement (not found)
程序员工具大全【持续更新】
wpa_cli参数说明
SSH password free login
回文数(简单版)
牛客网:判断是否为回文字符串
牛客网:合并区间
Flutter系列-flutter路由管理
如何在 FlowUs和Notion 等笔记软件中进行任务管理?
牛客网:最小覆盖子串
Cookie encryption 3+rpc solution
ssh免密码登录
数商云:解析B2B2C多用户商城系统架构设计思路,开启智能商城新时代
c# sqlsugar,hisql,freesql orm框架全方位性能测试对比之sqlserver










