xiaofeng666

shell格式的if语句:

[root@www file_test]# cat if.sh
#!/bin/bash
#if test
if [ $# -eq 0 ];then
  exit
fi
if [ $1 -eq 1 ];then
  echo "the num is : abc"
elif [ $1 -gt 2 ];then
  echo "the num is : 2-200"
else
  echo "the num is other"
fi
[root@www file_test]#

多分支if条件语句

    if [ 条件语句1 ]

       then

        执行程序1

    elif [ 条件语句2 ] 

      then

        执行程序2

     else

      执行程序2 

     fi

 

awk格式的if语句:
[root@www file_test]# awk -F: \'{if($3==0){print "管理员账号:"$1}else if($3>=1 && $3<1000){i++}else{j++}}END{print "系统账号个数:"i;print "普通账号个数:"j}\' passwd
管理员账号:root
系统账号个数:31
普通账号个数:1
[root@www file_test]#

分类:

技术点:

相关文章:

  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-07
  • 2021-11-23
  • 2021-06-10
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
相关资源
相似解决方案