li@ubuntu:~/test$ cat a.sh
#!/bin/bash for loop in 1 2 3 4 5
do
echo "The value is : $loop"
done echo for str in 'This is a string '
do
echo $str
done echo for file in $HOME/.bash*
do
echo $file
done li@ubuntu:~/test$ ./a.sh
The value is : 1
The value is : 2
The value is : 3
The value is : 4
The value is : 5 This is a string /home/li/.bash_history
/home/li/.bash_logout
/home/li/.bashrc
li@ubuntu:~/test$

while:

 li@ubuntu:~/test$ cat t.sh
#!/bin/bash while read number
do
echo "The number is $number"
done
li@ubuntu:~/test$ ./t.sh
5
The number is 5
4
The number is 4
9
The number is 9
8
The number is 8
2
The number is 2
^C
li@ubuntu:~/test$

Shell for while 循环的更多相关文章

  1. shell中的循环

    shell中的循环 for循环 类似于C语言的步长控制 例如: ;i<=;i++)); ); done 将1到10,依次乘以4,然后打印出来. 这里顺便提一下,shell里面表达式的计算,可以有 ...

  2. shell中for循环

    shell中for循环总结 最常用的就是遍历操作某一类文件,比如批量建索引. for i in `ls` do samtools faidx $i done 注意:for末尾不需要冒号(:),循环的代 ...

  3. shell中for循环总结

    关于shell中的for循环用法很多,一直想总结一下,今天网上看到上一篇关于for循环用法的总结,感觉很全面,所以就转过来研究研究,嘿嘿... 1. for((i=1;i<=10;i++));d ...

  4. shell脚本学习-循环

    跟着RUNOOB网站的教程学习的笔记 for循环 与其他编程语言类似,shell支持for循环. for循环一般格式为: for var in item1 item2 ... itemN do com ...

  5. 04 shell编程之循环语句

    Shell编程之循环语句 学习目标: 掌握for循环语句编程 掌握while循环语句编程 目录结构: For循环语句 l  读取不同的变量值,以逐个执行同一组命令 l  For语句结构 for 变量名 ...

  6. shell的for循环

    与其他编程语言类似,Shell支持for循环. for循环一般格式为: for 变量 in 列表 do command1 command2 ... commandN done 列表是一组值(数字.字符 ...

  7. Shell中的循环语句实例

    1.for循环语句实例1.1 最基本的for循环 #!/bin/bash for x in one two three four do     echo number $x done 注:" ...

  8. shell编程之循环语句for / while / until

    shell编程之循环语句与函数 一.条件测试 二.循环语句 ① for循环语句结构(遍历) 示例1 示例2 ② while循环语句结构(迭代) 示例1 示例2 ③ until 循环语句结构 示例1 一 ...

  9. shell脚本之循环语句与函数

    shell脚本之循环语句与函数 echo的用法: echo -n #表示不换行输出 echo -e #输出转义字符,将转义后的内容输出到屏幕上 转义字符: \n :换行,被输出的字符从"\n ...

  10. Shell编程之循环语句与echo的用法

    Shell编程之循环语句与echo的用法 目录 Shell编程之循环语句与echo的用法 一.echo用法 1. echo常用选项 2. 常用的转义字符 3. 特殊符号%.#的用法 二.循环语句 1. ...

随机推荐

  1. gh-ost:不一样的在线表结构变更

    简介: 2016年8月份,shlomi-noach在GitHub Engineering发文宣布gh-ost开源.gh-ost是什么?一个不依赖触发器实现的在线表结构变更工具. 对于数据库运维人员来说 ...

  2. 运维自动化ansible基础

    云计算三种服务架构 IAAS: 不提供OS  只购买硬件(网络,存储,计算) PAAS: 提供硬件和OS和开发和运行环境  只需要开发应用软件 SAAS: 提供 硬件 os 软件   相当于直接购买软 ...

  3. WIN32,_WIN32_WIN64

    MSDN 里说,VC 有 3 个预处理常量,分别是 _WIN32,_WIN64,WIN32. 只要包含了 Windows.h,那么 WIN32 常量是肯定定义了的,所以不能用于判断平台环境(如果x64 ...

  4. 282A

    #include <iostream> #include <string> using namespace std; int main() { int n, plus, sub ...

  5. api-gateway-engine知识点(1)

    1     密钥绑定时,通过Channel 实现监控 后台发送数据 :      redisTemplate.convertAndSend(RedisMessageChannel.API_GATEWA ...

  6. Python 全栈开发六 常用模块学习

    本节大纲: 模块介绍 time &datetime模块 random os sys shutil json & picle shelve configparser hashlib 一. ...

  7. jenkins 邮箱配置---腾讯企业邮箱

    一,简单设置 1.登陆jenkins--> 系统管理 ---> 系统设置 2.邮箱就是发送者的邮箱,密码是登陆邮箱的密码 3.设置完以后,可以点击‘test configuration’, ...

  8. vue中定时器的使用方式

    就这么搞定 no no no  离开页面的时候还必须清楚定时器

  9. teragen/terasort_简化版

    1, 关闭Hadoop安全模式 进入hdfs用户 su – hdfs Cd /opt/cloudera/parcels/CDH-5.12.1-1.cdh5.12.1.p0.3/bin hdfs dfs ...

  10. (1)Python3笔记 数据类型之Number与String

    一.Number(数值) 1) 整数 : int 2) 浮点数: float type(1) //int type(1.0) // float type(1+1) // int , 2 type(1+ ...