If to determine the size of two values -- multi-branch if statement to strictly judge the parameters
#! /Bin/bash
Print_usage (){
Printf "the number of parameters you entered is incorrect or incorrect. Run the following syntax: \ n"
Echo-e "$0 digit 1 digit 2"
Exit1
}
If [$ #-ne 2]
Then
Print_usage
Exit1
Fi
[-N "'echo $1 | SED's/[0-9] // g''"-a-n "'echo $2 | SED's/[0 -9] // g'' "] & Echo" Both parameters must be numbers "& Exit 1
[-N "'echo $1 | SED's/[0-9] // g''"] & Echo "the first parameter must be a number" & Exit 1
[-N "'echo $2 | SED's/[0-9] // g''"] & Echo "the second parameter must be a number" & Exit 1
If [$1-GT $2]
Then
Echo "$1> $2"
Elif [$1-lt $2]
Then
Echo "$1 <$2"
Else
Echo "$1 = $2"
Fi
1. Single judgment syntax
[-N "'echo $1 | SED's/[0-9] // g''"] & Echo "the first parameter must be a number" & Exit 1
[-N "'echo $2 | SED's/[0-9] // g''"] & Echo "the second parameter must be a number" & Exit 1
2. Normal variable judgment
[-N "'echo $2 | SED's/[0-9] // g''"] & {
Echo "the second parameter must be a number"
Exit1
}
If to determine the size of two values -- multi-branch if statement to strictly judge the parameters