1.1.
various Judgments1.1.1.
string Judgments
STR1 = str2 When two strings have the same content, length is true
Str1! = str2 true when string str1 and str2 are not equal
-N str1 True when the length of the string is greater than 0 ( string non-null )
-Z str1 true when the string length is 0 ( empty string )
str1 is true when string str1 is not empty
1.1.2.
the judgment of the numbers
Int1-eq int2 Two numbers equal to True
Int1-ne Int2 Two number is true
INT1-GT int2 int1 greater than Int2 is true
Int1-ge int2 int1 greater than or equal to Int2 true
Int1-lt int2 int1 less than int2 is true
Int1-le int2 int1 less than or equal to Int2 true
1.1.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 files are directory-True
-C file file is true for character special files
-B file files are true for block special files
-S file files non- 0 true
-T file is true when the specified device is terminal ( default = 1)
1.1.4.
Complex logic judgment
-A and
-O or
! Non-
1.2.
Conditional Judgment
If [$a-eq $b]
Then
Echo 111
Elif [-F $path]
Echo 222
Fi
In a conditional expression, there can be spaces around the equals sign. However, in an assignment statement outside of an expression,the shell cannot have spaces.
The equal sign in the shell is also interesting, when judging the inside of a statement, and in other places it means assigning.
The sentence inside the brackets must have a space left and right, or the judgment statement will not take effect.
1.3.
Looping Statements
For I in list
Do
Echo 111
Done
You can also list the data that you want to traverse in the back of in.
while [$a! = 0]
Do
Echo 222
Done
in the Loop statement, the return value exits the current function and returns the values that are called for the function's return value. the continue exits the loop and executes the next loop. Exit exits the current function and returns the execution result of the function for $? called.
Shell Common Command Summary (i)