shell 判断大小

 

test.sh

#!/bin/bash
read -p ""  a
read -p ""  b

if [ $a -eq $b ];then
    echo "="
elif [ $a -gt $b ];then
    echo ">"
elif [ $a -lt $b ];then
    echo "<"
fi

输出

bogon:Desktop macname$ ./test.sh 
2
6
<
bogon:Desktop macname$ ./test.sh 
6
2
>
bogon:Desktop macname$ ./test.sh 
6
6
=

 

 

参考:

https://www.cnblogs.com/jw15327/p/6114886.html

 

posted @ 2019-08-22 18:54  anobscureretreat  阅读(698)  评论(0编辑  收藏  举报