当前位置:网站首页>Shell编程之循环语句与函数
Shell编程之循环语句与函数
2022-08-03 23:01:00 【吉吉吉吉吉吉吉吉吉吉】
一、循环语句
1、for循环语句
2、for语句的结构
for 循环语句的语法结构
for 变量名 in 取值列表
do
命令序列
done
扩展:
for i in {1..50..2} 1-50的奇数
for i in {2..50..2} 1-50的偶数
for i in {10..1} 1-10倒序排列
for i in $(seq 10) 1-10正序排列
for i in $(seq 10 -1 1) 1-10倒序排列
for i in $(seq 1 2 10) 1-10的奇数,中间为步长
for i in $(seq 2 2 10) 1-10的偶数,中间为步长
3、语句应用示例
①打印1-5个数
②数字炸弹游戏Ⅰ: 要求在1-100内定义一个数字,与用户交互,要求,每次提醒用户,数字猜>大了还是猜小了,直到猜中为止,最后统计猜的次数
③10以内的奇数列举出来
边栏推荐
- [Paper Reading] TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve
- ML之yellowbrick:基于titanic泰坦尼克是否获救二分类预测数据集利用yellowbrick对LoR逻辑回归模型实现可解释性(阈值图)案例
- utils timer
- CAS:178744-28-0,mPEG-DSPE,DSPE-mPEG,甲氧基-聚乙二醇-磷脂酰乙醇胺供应
- 藏宝计划TreasureProject(TPC)系统模式开发技术原理
- The development status of cloud computing at home and abroad
- 软测人每个阶段的薪资待遇,快来康康你能拿多少?
- The sword refers to the offer question 22 - the Kth node from the bottom in the linked list
- Take an example of a web worker
- On the Qixi Festival of 2022, I will offer 7 exquisite confession codes, and at the same time teach you to quickly change the source code for your own use
猜你喜欢
设置工作模式与环境(下):探查和收集信息
FinClip最易用的智能电视小程序
响应式织梦模板塑身瑜伽类网站
override learning (parent and child)
重发布实验报告
Interpretation of ML: A case of global interpretation/local interpretation of EBC model interpretability based on titanic titanic rescued binary prediction data set using interpret
Summary bug 】 【 Elipse garbled solution project code in Chinese!
BMN: Boundary-Matching Network for Temporal Action Proposal Generation阅读笔记
navicat 连接 mongodb 报错[13][Unauthorized] command listDatabases requires authentication
易观分析:2022年Q2中国网络零售B2C市场交易规模达23444.7亿元
随机推荐
Live Preview | Build Business Intelligence, Quickly Embrace Financial Digital Transformation
Create function report error, prompting DECLARE definition syntax problem
websocket多线程发送消息报错TEXT_PARTIAL_WRITING--自旋锁替换synchronized独占锁的使用案例
[N1CTF 2018] eating_cms
Zilliz 2023 Fall Campus Recruitment Officially Launched!
如何创建一个Web项目
UVa 1025 - A Spy in the Metro (White Book)
FinClip,助长智能电视更多想象空间
静态文件快速建站
How many way of calling a function?
Scala基础【正则表达式、框架式开发原则】
SolidEdge ST8安装教程
The development status of cloud computing at home and abroad
二叉搜索树解决落叶问题
redis持久化方式
Software testing is seriously involution, how to improve your competitiveness?
一个函数有多少种调用方式?
响应式织梦模板餐饮酒店类网站
Work Subtotal QT Packing
[Paper Reading] TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve