加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell条件语句

发布时间:2020-12-15 21:38:31 所属栏目:安全 来源:网络整理
导读:if (表达式); 语句1 elif 语句2 else fi ? if(())用户判断大小 #!/bin/ bash#auto if testNUM = 100 NUM1 = 200 if (($NUM$NUM1)); then echo " this $NUM greate $NUM1 " else echo " this $NUM XIAOU $NUM1 ? 逻辑运算符解析: -f ?判断文件是否存在 -d判

if (表达式);

语句1

elif

语句2

else

fi

?

if(())用户判断大小

#!/bin/bash
#auto if test

NUM=100

NUM1=200

if (($NUM>$NUM1));then
        echo "this $NUM greate $NUM1 "
else
        echo   "this  $NUM  XIAOU $NUM1

?

逻辑运算符解析:
-f ?判断文件是否存在

-d判断目录是否存在

-gt 大于

-z 空字符串

[email?protected]:/home/yisheng/shell# /bin/bash -n 5.sh
[email?protected]-v-m:/home/yisheng/shell# 

-n用于测试代码是否正确,无输出为正确

?

#!/bin/bash
#by hou 2019

DIR=/tmp/2019

if [ ! -d $DIR ];then
        mkdir -p $DIR
        echo -e "33[32mthis $DIR create success!33[0m"
else
        echo -e "33[32mthis $DIR exit!33[0m"
fi

判断目录是否存在

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读