linux shell script 循环语句
来源:互联网 发布:视频会议录播软件 编辑:程序博客网 时间:2024/05/22 21:30
1. while 语句
1. while do done格式while [condition]do program blockdone
例子:
#/bin/bash echo "====while test ====" i=0 cat ./1.c | while read line #该while相当于依次将1.c文件中每行字符串取出,并赋值给line变量 do echo $line cd $line git log | grep "Sat Oct 10" cd - done
#/bin/bash echo "====while test ====" i=0 cat ./git.log | while read line do len=${#line} #该指令是获取line字符串的长度 len_1=$len-4 line_1=${line:0:$len_1} #该指令是从line字符串的第0个字符开始取$len_1个字符组成的字符串赋值给line_1 echo $line_1 repo sync $line_1 done
2. until语句
2. until do done格式:until [condition]doprogram blockdone
3. for语句
3. for do done格式:for variable_name in content1 content2 content3 ...doprogram blockdone
例子:
fl=$(ls "$dir")for name in $fl #该for相当于将fl字符串中以空格为间隔依次取出,并赋值给name变量do program blockdone
0 0
- linux shell script 循环语句
- linux shell for 循环语句
- Shell Script控制语句
- linux shell script程序之循环结构简介
- 【Unix/Linux.Shell Script】Shell Script程序的流程控制语句
- 【Unix/Linux.Shell Script】Shell & Shell Script
- 关于linux shell script if 语句特定参数的备忘
- linux中的shell script 的流程控制语句
- Linux Shell基础知识7 循环语句
- shell script中的循环语法
- LINUX shell script 打包
- linux shell script 入门
- linux shell script 函式
- linux shell script
- Linux shell script
- [linux]shell script 随记
- Linux Shell Script Study
- FTP linux shell script
- 《Linux Shell》笔记之dig
- [Android开发从零开始].2.模拟器的使用.mp4
- 时间空间复杂度
- asp.net之cookie(设置css)
- 协同过滤
- linux shell script 循环语句
- 【10/26】 iOS开发成长之路,【从零开始】
- 《Linux Shell》笔记之grep
- Android添加顶部通知
- Android Activity 启动模式
- error exception runtimeexception
- 《Linux Shell》笔记之正则表达式
- nodeJs get post
- 进击的KFC第七节:C语言:结构体篇