当前位置:网站首页>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以内的奇数列举出来
边栏推荐
- 响应式织梦模板餐饮酒店类网站
- Creo 9.0二维草图的诊断:重叠几何
- 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
- 一个函数有多少种调用方式?
- 完全二叉树问题
- Research status of target detection at home and abroad
- MiniAPI of .NET6 (14): Cross-domain CORS (Part 1)
- The development status of cloud computing at home and abroad
- [RYU] rest_router.py source code analysis
- Kotlin - 扩展函数和运算符重载
猜你喜欢
Boss: There are too many systems in the company, can you realize account interoperability?
【day6】类与对象、封装、构造方法
Embedded Systems: GPIO
《数字经济全景白皮书》金融数字用户篇 重磅发布!
静态文件快速建站
单例模式使用饿汉式和懒汉式创建一定安全?很多人不知
BMN: Boundary-Matching Network for Temporal Action Proposal Generation阅读笔记
[MySQL Advanced] Creation and Management of Databases and Tables
密码学基础以及完整加密通讯过程解析
ML之interpret:基于titanic泰坦尼克是否获救二分类预测数据集利用interpret实现EBC模型可解释性之全局解释/局部解释案例
随机推荐
Testng listener
逆波兰表达式求值
Zilliz 2023 秋季校园招聘正式启动!
The principle and use of AOSP CameraLatencyHistogram
数据分析知识点搜集(纯粹的搜集)
HDU 5655 CA Loves Stick
encapsulation, package, access modifier, static variable
HCIP BGP lab report
golang写的存储引擎,基于b+树,mmap
FinClip最易用的智能电视小程序
Summary bug 】 【 Elipse garbled solution project code in Chinese!
IELTS essay writing template
PowerMockup 4.3.4::::Crack
Unity2021 releases WebGL fog effect disappearing problem
冰河又一MySQL力作出版(文末送书)!!
软测人每个阶段的薪资待遇,快来康康你能拿多少?
The salary of soft testers at each stage, come to Kangkang, how much can you get?
pikachu Over permission
OPC UA 与IEC61499 深度融合(1)
Internet user account information management regulations come into effect today: must crack down on account trading and gray products