1.判断变量

read -p "input a word :" word
 if  [ ! -n "$word" ] ;then
     echo "you have not input a word!"
 else
     echo "the word you input is $word"
 fi

2.判断输入参数

#!/bin/bash
 if [ ! -n "$1" ] ;then
     echo "you have not input a word!"
 else
     echo "the word you input is $1"
 fi

3.判断赋值变量

TMOUT=`cat /etc/profile | grep TMOUT | awk -F[=] '{print $2}'`
echo $TMOUT

if [ ! $TMOUT ];then # 如果TMOUT为none
        echo "[ X ] 账号超时不存在自动注销,不符合要求,建议设置小于600秒" >> out.txt
else
        if [ $TMOUT -le 600 -a $TMOUT -ge 10 ] ; then
                echo "[ √ ] 账号超时时间${TMOUT}秒,符合要求" >> out.txt
        else
                echo "[ X ] 账号超时时间$TMOUT秒,不符合要求,建议设置小于600秒" >> out.txt

 

from

相关文章:

  • 2021-07-22
  • 2022-12-23
  • 2022-01-08
  • 2021-12-18
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
相关资源
相似解决方案