💻
ExistOrLive' Gitbook
  • README
  • ReadMe
  • 开发语言学习
    • Python
      • 0.概述
      • 1.基本数据类型
      • 2.变量
      • 3.函数
      • 4.运算符
      • 5.字符串
      • 6.列表
      • 7.元组
      • 8.集合
      • 9.字典
      • 10.流程控制
      • 12.函数
      • 13.模块
      • 14.输入输出格式化
      • 15.面向对象
    • Swift
      • 1.基础部分
        • 常量和变量以及基本类型_1
        • 常量和变量以及基本类型_2
      • 2.基本运算符
        • 基本运算符
      • 3.字符串和字符
        • 字符串
        • 字符串操作
      • 4.集合类型
        • 概述
        • Array
        • Set
        • Dictionary
      • 6.函数
        • 函数
        • 函数返回值
        • 函数类型
      • 7.闭包
        • 闭包
        • 闭包表达式
        • 尾随闭包
        • 捕获变量或常量
        • 闭包是引用类型
        • 逃逸闭包
        • 自动闭包
      • 8.枚举
        • 枚举
        • 枚举与switch语句
      • 9.类和结构体
        • 类和结构体
        • 属性
          • 属性
          • 属性观察器
          • 属性包装器
          • 全局变量和局部变量
          • 类属性
        • 方法
    • Shell
      • Shell变量和基本类型
      • Shell函数
      • Shell基本运算符
      • Shell脚本的参数
      • Shell流程控制
      • Shell输入输出
      • Shell文件包含
  • iOS
    • UI
      • UIKit
        • UIView
          • UIView
          • drawRect
        • UITableView
          • UITableView
          • UITableView的加载过程
  • 学习开发工具
    • 静态分析
      • OCLint
      • infer
      • SwiftLint
    • iOS构建工具
      • fastlane
        • fastlane
        • fastlane的安装
        • fastlane一键打包
        • fastlane证书管理
    • Cocoapods
      • 安装pod库-podfile
      • 创建pod库-podspec
  • 开源库
    • Tool
      • Swiftlint源码学习
      • 利用Swiftlint自定义规则实现自动化code review
由 GitBook 提供支持
在本页
  • 1. if 语句
  • 2. for 循环语句
  • 3. while循环
  • 4. 无限循环
  • 5. case...esac
  • 6. break/continue

这有帮助吗?

在GitHub上编辑
  1. 开发语言学习
  2. Shell

Shell流程控制

1. if 语句

if then elif else fi 等关键字构成基本的 if 语句

if [ condition ]
then 
    # code
elif [ condition ]
then 
    # code
else 
    # code
fi 

2. for 循环语句

for in do done

for item in itemArray
do 

    # code
done

3. while循环

while [ condition ]
do 

    # code

done

循环读取键盘信息 ​

while read param
do 
    echo "输入的参数为$param"
done

4. 无限循环

while :
do 

   #code
done 


while true
do 

   #code
done 


for (( ; ; ))
do
   #code
done

5. case...esac

*相当于 default

 # 模式
case 值 in
模式1)  #code
;;
模式2)  #code 
;;
模式3|模式4|模式5) #code
;;
*)  #code 
;;
esac


# 例子
echo "请输入:"
read param

case $param in
1) echo "第一种模式"
;;
2) echo "第二种模式"
;;
3|4|5|6) echo "第3/4/5/6种模式"
;;
*) echo "其他模式"
;;
esac

6. break/continue

上一页Shell脚本的参数下一页Shell输入输出

最后更新于3年前

这有帮助吗?