題目:任意輸入兩個整數,比較他們的大小express
[root@cnsz142728 scripts]# vim pupu.sh #!/bin/bash a=$1 b=$2 if [ $# -ne 2 ];then echo "USAGE:$0 arg1 arg2" exit 2 fi expr $a + 1 &>/dev/null start=$? expr $b + 1 &>/dev/null start1=$? if [ $start -ne 0 -a $start1 -ne 0 ]; then echo "Please input two again" exit 33 fi if [ $a -eq $b ];then echo "$a=$b" elif [ $a -lt $b ];then echo "$a<$b" elif [ $a -gt $b ];then echo "$a>$b" fi ~ "pupu.sh" [New] 23L, 357C written [root@cnsz142728 scripts]# chmod +x pupu.sh [root@cnsz142728 scripts]# ./pupu.sh USAGE:./pupu.sh arg1 arg2 [root@cnsz142728 scripts]# ./pupu.sh 3 3 ./pupu.sh: line 13: [: -a: integer expression expected 3=3 [root@cnsz142728 scripts]# ./pupu.sh 3 4 ./pupu.sh: line 13: [: -a: integer expression expected 3<4 [root@cnsz142728 scripts]# ./pupu.sh 3 1 ./pupu.sh: line 13: [: -a: integer expression expected 3>1 [root@cnsz142728 scripts]# ./pupu.sh 2.2 2.2 Please input two again