1.条件控制 关键字 if.elif.else 一般形式如下: if 条件1: 结果1 elif 条件2: 结果2 else: 结果3 注意:条件后的:语句的缩进的是相同的 2.循环语句 关键字有 for 和 while 2.1 while 一般形式如下: while 判断条件: 语句 while ... else... while 条件: true else false 2.2 for for循环可以遍历任何序列的项目,如一个列表或者一个字符串. for循环的一般格式如下:…
参考博客: [1]Shell脚本的条件控制和循环语句 一.条件控制语句 1.if语句 1.1语法格式: if [ expression ] then Statement(s) to be executed if expression is true fi 注意:expression 和方括号([ ])之间必须有空格,否则会有语法错误. if 语句通过关系运算符判断表达式的真假来决定执行哪个分支.Shell 有三种 if ... else 语句: if ... fi 语句 if ... else…
SHELL学习笔记----IF条件判断,判断条件 前言: 无论什么编程语言都离不开条件判断.SHELL也不例外. if list then do something here elif list then do another thing here else do something else here fi EX1: #!/bin/bash if [ `uname -m` == "x86_64" ]…