1. Numerical comparison
! /bin/Bashecho"Enter a score:"Read NUM1if[$num 1-ge the]then Echo"Very Good"elif [$num 1-lt the-A $num 1-ge -]then Echo"Good"ElseEcho" Low"fi
which
-eq equals
-ne Not equal to
-lt less than
-le less than or equal to
-GT Greater than
-ge greater than or equal to
Equal equals not equal does not equal less than greater greater than
Elif is also the else if
-A and
-O OR
2, ((..)) and [[...]] The use
Echo"Enter a score:"Read Num2if(($num 2 >= the) then echo"Very Good"elif [[$num 2-lt the&& $num 2-ge -]]then Echo"Good"ElseEcho" Low"fi
3. String and file status test
#! /bin/Bashecho"enter filename or workname:"Read Name1if[ -z $name 1]then Echo"your enter is null"ExitElse if[ -F $name 1] then echo"This is a file"Elif [-d $name 1] then echo"This is a workspace" ElseEcho"Not found file or workspace"Fifi
-Z is an empty string (length of 0) returns True
-N is a non-empty string when returning true
-D is present and is a directory when returning True
-F exists and is normal file returns True
Linuxshell Script Programming Basics 5--Numeric, string, file status test, ((..)) and [[...]] The use