控制流结构
来源:互联网 发布:大数据项目经理 面试 编辑:程序博客网 时间:2024/05/16 18:06
控制流结构
一. 退出状态
1. $ echo $? 最后命令退出状态
2. $$ || 控制次序命令
3. exit n 退出当前进程
4.
二.if 语句
if condition
if condition
then
command1 if condition is true or if exit status
of condition is 0 (zero)
...
...
fi
if...else...fi
If given condition is true then command1 is executed otherwise command2 is executed.
Syntax:if condition then condition is zero (true - 0) execute all commands up to else statement else if condition is not true then execute all commands up to fi fiif-then-else
Syntax:if condition then condition is zero (true - 0) execute all commands up to elif statement elif condition1
then condition1 is zero (true - 0) execute all commands up to elif statement elif condition2 then condition2 is zero (true - 0) execute all commands up to elif statement else None of the above condtion,condtion1,condtion2 are true (i.e. all of the above nonzero or false) execute all commands up to fi fi
if 条件
then 命令
fi
三.
1.变量值测试
2.Gerp输出检查
3.用变量检查grep输出
4.文件拷贝输出检查
5.当前目录测试
6.文件权限测试:用if语句测试文件权限
7.测试传递到脚本中的参数
$# 表示调用参数的个数
四.Case语句
Case 值 in
模式1}
命令1
…
;;
模式2}
命令2
…
;;
Esac
五.for
1.对for循环使用参数
在for循环中省去in列表,它将接受命令行位置参数作为参数
for params in “$@” 或 for params in “$*”
2. for循环嵌套使用
for 变量名1 in 列表1
do
for 变量名2 in 列表2
do 命令1
done
done
六.Until
Until 循环执行一系列命令直到条件为真时停止
格式
Until 条件
命令1
done
七.While 循环
while 命令
do
命令1
命令2
done
- Shell控制结构--流控制
- 控制流结构
- 控制流结构
- shell控制流结构
- 控制流结构
- 控制流结构
- 控制流结构
- Shell控制流结构笔记
- 控制结构
- 控制结构
- 控制结构
- 控制结构
- 控制结构
- 控制结构
- shell_04控制流结构_笔记
- shell脚本中的控制流结构
- 控制流结构--shell编程笔记
- shell脚本中的控制流结构
- 泛型算法系列24:set_difference()
- 安静地写下第一个标题
- 访问远程 DBISAM 数据库的方法
- 你有值得坚持的事么?咱一块坚持吧
- 项目管理手记(20) 中国制造业的隐痛--非理性思维下的信息化投入
- 控制流结构
- 四. 非阻塞通信
- how to view signed jar expiration time
- ISNULL AND NULLIF 的区别
- 初等数学公式
- PHP防止错误信息显示暴露,影响安全的解决办法
- JS中 去除字符串 空格
- TMG(ISA 2008) 王者再现
- Error initializing endpoint java.net.BindException :Address already in use:JVM_Bind:80 (8080).