if statement to determine:
Instance:
#!/bin/sh
# This A is test ssh scrpt
echo "Plase input a number:"
Read-p A
#echo "Your number is ${a}"
if [$a = "1"]; Then echo "Linux";
elif [$a = "2"]; Then echo "Solaris";
else echo "What?";
Exit
fi;
1 string Judgment
STR1 = str2 When two strings have the same content, the length is true
STR1!= str2 is true when strings str1 and str2 are unequal
-N str1 True when the length of the string is greater than 0 (string not empty)
-Z str1 True when the length of the string is 0 (empty string)
STR1 is True when string str1 is Non-null
2 judgement of the numbers
Int1-eq int2 Two number equal to True
Int1-ne Int2 Two is not equal to the true number
INT1-GT Int2 int1 greater than Int2 is true
Int1-ge Int2 Int1 is greater than or equal to Int2 is true
Int1-lt Int2 Int1 is less than int2 true
Int1-le Int2 Int1 is less than or equal to Int2 true
3 The judgment of the document
-r file user readable as True
-W file user can write as true
-X file user can execute as true
-F file is true for regular files
-D file is true for directory
-C file is true for character special files
-B file is a block special file is True
-S file file non-0 o'clock is true
-T file True when the device specified by the file descriptor (default is 1) is a terminal
3 Complex logic judgments
-A and
-O or
! Non -