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

边栏推荐
- Research status of target detection at home and abroad
- PowerMockup 4.3.4::::Crack
- ML之interpret:基于titanic泰坦尼克是否获救二分类预测数据集利用interpret实现EBC模型可解释性之全局解释/局部解释案例
- CAS:178744-28-0,mPEG-DSPE,DSPE-mPEG,甲氧基-聚乙二醇-磷脂酰乙醇胺供应
- V8中的快慢数组(附源码、图文更易理解)
- HCIP BGP实验报告
- Pytest learn-setup/teardown
- [2022安恒夏令营] 5个小题
- 二叉搜索树解决落叶问题
- Creo 9.0在草图环境中创建坐标系
猜你喜欢

Pytest learn-setup/teardown

Code Casual Recording Notes_Dynamic Programming_416 Segmentation and Subsetting

Embedded Systems: GPIO

【开源框架】国内首个通用云计算框架,任意程序都可做成云计算。

BMN: Boundary-Matching Network for Temporal Action Proposal Generation Reading Notes

LabVIEW code generation error 61056

密码学基础以及完整加密通讯过程解析

Zilliz 2023 Fall Campus Recruitment Officially Launched!

Fluorescein-PEG-CLS, cholesterol-polyethylene glycol-fluorescein scientific research reagent

What is Adobe?
随机推荐
Pytest learn-setup/teardown
.NET6之MiniAPI(十四):跨域CORS(上)
伴随着元宇宙、web3.0等概念的兴起,数字人、数字场景等诸多数字化的形态开始出现
Work Subtotal QT Packing
Lift, Splat, Shoot: Encoding Images from Arbitrary Camera Rigs by Implicitly Unprojecting to 3D 论文笔记
牛客2022 暑期多校3 H Hacker(SAM + 线段树查询区间内部最大子段和)
什么是memoization,它有什么用?
数据分析知识点搜集(纯粹的搜集)
2022-08-03 Oracle executes slow SQL-Q17 comparison
最小化安装debian11
【RYU】rest_router.py源码解析
Research status of target detection at home and abroad
With 4 years of work experience, the 5 communication methods between multi-threads can't be said, can you believe it?
OPC UA 与IEC61499 深度融合(1)
The development status of cloud computing at home and abroad
Zilliz 2023 秋季校园招聘正式启动!
Unity2021发布WebGL雾效消失问题
golang写的存储引擎,基于b+树,mmap
Diazo Biotin-PEG3-DBCO | Diazo Compound Modified Biotin-Tripolyethylene Glycol-Dibenzocyclooctyne
软测人每个阶段的薪资待遇,快来康康你能拿多少?