0
点赞
收藏
分享

微信扫一扫

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



if的大小比对:

#!/bin/sh

a=10
b=20

if [ $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 条评论