qfedu-linux-advanced-level/day1/d16.sh

55 lines
656 B
Bash
Raw Permalink Normal View History

2023-08-14 15:53:04 +08:00
#!/bin/bash
# -eq 是等于
test "$1" -eq "$2"
if [ $? -eq 0 ]
then
echo "$1 == $2"
else
echo "$1 != $2"
fi
# -gt 是大于
test "$1" -gt "$2"
if [ $? -eq 0 ]
then
echo "$1 > $2"
else
echo "$1 !> $2"
fi
# -lt 是小于
test "$1" -lt "$2"
if [ $? -eq 0 ]
then
echo "$1 < $2"
else
echo "$1 !< $2"
fi
# -ge 是大于等于
test "$1" -ge "$2"
if [ $? -eq 0 ]
then
echo "$1 >= $2"
else
echo "$1 !>= $2"
fi
# -le 是小于等于
test "$1" -le "$2"
if [ $? -eq 0 ]
then
echo "$1 <= $2"
else
echo "$1 !<= $2"
fi
# -ne 是不等于
test "$1" -ne "$2"
if [ $? -eq 0 ]
then
echo "$1 != $2"
else
echo "$1 == $2"
fi