当前位置:网站首页>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以内的奇数列举出来

边栏推荐
- [2022强网杯] polydiv和gamemaster
- Network basic learning series four (network layer, data link layer and some other important protocols or technologies)
- Fluorescein-PEG-CLS, cholesterol-polyethylene glycol-fluorescein scientific research reagent
- Creo 9.0创建几何点
- Embedded systems: overview
- 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
- OPC UA 与IEC61499 深度融合(1)
- 【职场杂谈】售前与销售工作配合探讨
- utils timer
- 最小化安装debian11
猜你喜欢

易观分析:2022年Q2中国网络零售B2C市场交易规模达23444.7亿元

HCIP BGP实验报告

The principle and use of AOSP CameraLatencyHistogram

MiniAPI of .NET6 (14): Cross-domain CORS (Part 1)

LabVIEW code generation error 61056

Zilliz 2023 Fall Campus Recruitment Officially Launched!

override学习(父类和子类)

node连接mysql数据库报错:Client does not support authentication protocol requested by server

ML之interpret:基于titanic泰坦尼克是否获救二分类预测数据集利用interpret实现EBC模型可解释性之全局解释/局部解释案例

FinClip最易用的智能电视小程序
随机推荐
Redis persistence method
数据分析知识点搜集(纯粹的搜集)
易观分析:2022年Q2中国网络零售B2C市场交易规模达23444.7亿元
Live Preview | Build Business Intelligence, Quickly Embrace Financial Digital Transformation
CAS:178744-28-0,mPEG-DSPE,DSPE-mPEG,甲氧基-聚乙二醇-磷脂酰乙醇胺供应
The salary of soft testers at each stage, come to Kangkang, how much can you get?
HCIP BGP lab report
Code Casual Recording Notes_Dynamic Programming_416 Segmentation and Subsetting
Scala基础【正则表达式、框架式开发原则】
获国际权威认可 | 云扩科技入选《RPA全球市场格局报告,Q3 2022》
1067 Sort with Swap(0, i)
栈的压入、弹出序列
ML之interpret:基于titanic泰坦尼克是否获救二分类预测数据集利用interpret实现EBC模型可解释性之全局解释/局部解释案例
藏宝计划TreasureProject(TPC)系统模式开发技术原理
What is memoization and what is it good for?
【论文阅读】TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve
响应式织梦模板餐饮酒店类网站
UVa 1025 - A Spy in the Metro (White Book)
Unity2021 releases WebGL fog effect disappearing problem
OPC UA 与IEC61499 深度融合(1)