Linux学习3之shell的if大小比对使用

来源:互联网 发布:淘宝店主自拍文胸 编辑:程序博客网 时间:2024/06/06 15:52


if的大小比对:

#!/bin/sha=10b=20if [ $a == $b ]then   echo "a is equal to b"elif [ $a -gt $b ]then   echo "a is greater than b"elif [ $a -lt $b ]then   echo "a is less than b"else   echo "None of the condition met"fi


a is less than b


if的使用:

if ... fi 语句;if ... else ... fi 语句;if ... elif ... else ... fi 语句。

需要注意then

具体使用:

if [ $(echo $endTime | cut -d '.' -f 2) -gt $(echo $startTime | cut -d '.' -f 2) ]; then  ... fi



参考:

【1】 http://c.biancheng.net/cpp/view/7005.html

0 0
原创粉丝点击