复习

运算

Linux - 第六天 shell脚本if for while 和awkLinux - 第六天 shell脚本if for while 和awk

if

  1. 语法:if [ 判断语句 ];then
  2. 注意语法格式!!!
  3. #单层if
    if [ 判断语句 ];then
        echo "执行语句"
    fi
    
    
    # if else
    if [判断语句];then
        echo "执行语句"
    elif [判断语句];
        echo "执行语句"
    else 
        echo "执行语句"
    fi
    
    
    # 多个判断语句 [判断语句] ||/&& [判断语句];then
    

     

for

  1. 基本语法
    1.  

      #使用命令查找文件 作为伪数组  遍历操作
      for i in `find /var/log -name "*.log"`
      do
          echo "操作"
      dong
      
      #操作一堆
      for i in {1..10} #1~10
      do
          echo "操作"
      dong
      /
      for i in 1 a d g s f
      do
          echo $i #读取组
      done
      #类java
      for (( i=0; i<10; i++ ))
      do
          echo $i
      done
  2.  
  3.  

while

  1. 语法
  2. Linux - 第六天 shell脚本if for while 和awk 2
  3.  
  4.  

awk

  1. 1Linux - 第六天 shell脚本if for while 和awk
  2. 2Linux - 第六天 shell脚本if for while 和awk
  3. Linux - 第六天 shell脚本if for while 和awk

 

 

补充

  1. Linux - 第六天 shell脚本if for while 和awk  写入某个文件
  2. Linux - 第六天 shell脚本if for while 和awk声明变量 declare -i num = 0

相关文章:

  • 2022-02-08
  • 2021-12-08
  • 2021-04-03
  • 2021-11-25
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2022-02-04
相关资源
相似解决方案