DevelopmentShellscripts are implemented with script arguments , respectively, andReadRead inthe way to compare2an integer size. Use conditional expressions (prohibitif) and remind the user to compare the results in the form of a screen output. Note: Altogether is the development2a script. When you use script to pass parameters andReadthe way you read it requires a hint about whether the variable is a numeric number, and how many arguments are not passed.
Read in mode
#!/bin/bashread-p "Pls input" num: "a b #no1 [-Z" $a "] | | [-Z "$b"] && {echo "Pls input" num again. " Exit 1} #no2expr $a + ten &>/dev/nullretval1=$?expr $b + &>/dev/nullretval2=$?test $RETVAL 1-eq 0-a $RETVA L2-eq 0 | | {echo "pls input" num "again." Exit 2} #num3 [$a-lt $b] &&{echo "$a < $b"} #num4 [$a-eq $b] &&{echo "$a = $b"} #num5 [$a-gt $b] &am P;&{echo "$a > $b"}
Script-Pass Reference
#!/bin/basha=$1b=$2#no1[$#-ne 2] &&{echo "usage:$0 NUM1 NUM2" Exit 1} #no2expr $a + &>/dev/nullretval1= $?expr $b + &>/dev/nullretval2=$?test $RETVAL 1-eq 0-a $RETVAL 2-eq 0 | | {echo "pls input" num "again." Exit 2} #num3 [$a-lt $b] &&{echo "$a < $b"} #num4 [$a-eq $b] &&{echo "$a = $b"} #num5 [$a-gt $b] &am P;&{echo "$a > $b"}
Shell Script-Compare two integer sizes