当前位置:网站首页>流程控制—if语句
流程控制—if语句
2022-07-22 10:51:00 【八点十面】
1、单分支if条件语句
if [ 条件判断式 ] ;then
程序
fi
另一种格式
if [ 条件判断式 ]
then
程序
fi
单分支条件语句需要注意几个点
* if语句使用fi结尾,和一般语言使用大括号结尾不同
* [ 条件判断式 ] 就是使用test命令判断,所以中括号和条件判断式之间必须有空格
* then后面跟符合条件之后执行的程序,可以放在[]之后,用“;”分割,也可以换行写入。
2、双分支if条件语句
if [ 条件判断式1 ]
then
条件成立时,执行的程序
else
条件不成立时,执行另一个程序
fi
3、多分支if条件语句
if [ 条件判断式1 ]
then
当条件1成立时,执行程序1
elif [ 条件判断式2 ]
then
当条件判断式2成立时,执行程序2
....省略更多条件...
else
当所有条件都不成立时,最后执行此程序
fi
边栏推荐
猜你喜欢
Constructive common centroid placement and routing of binary weighted capacitor arrays
微信小程序入门教程学习笔记——UI篇之操作反馈
Automatic generation of common centroid capacitance array with arbitrary capacitance ratio
Install pycharm
Multithreading 05 -- reentrantlock principle
网络基础知识
【FPGA】:ip核--ibert
Jmeter性能测试
Multithreading 03 -- synchronized and lock escalation
微信小程序Cannot read property 'setData' of null错误
随机推荐
Airtest test framework construction
Automatic generation of common centroid capacitance array with arbitrary capacitance ratio
postgre数据库
字符串split操作到底有多少坑
微信小程序综合案例实践2
网络基础知识
Parasitic sensing size and detailed routing of binary weighted capacitors in charge graded DAC
Monkey 介绍及使用
ThreadLocal encountered data problems in thread pool and Solutions
结构体和联合体
测试开发
尾插法构造链表
测试相关基础概念
使用多种加权方法在 SAR ADC 中放置二进制加权电容阵列
适用于高密度或高精度应用的高度可配置和可扩展的螺旋电容器设计
Spark学习之SparkSQL
Airtest测试框架搭建
微信小程序入门教程学习笔记——UI篇之操作反馈
LeetCode - 整数反转
信号耦合约束下扭曲共质心电容器阵列的布线能力