zoukankan      html  css  js  c++  java
  • Shell脚本判断内容为None的方式

    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

  • 相关阅读:
    cpuset
    top
    path-lookup
    strace
    IDR算法[原理]
    cgroup
    转载
    std::reverse_iterator::base
    可重入、不可重入
    chromium code 中 普遍使用的 C++11 语法
  • 原文地址:https://www.cnblogs.com/tdcqma/p/6723589.html
Copyright © 2011-2022 走看看