if condition judgment; Then
Statment
Else
Statment
Fi
Or
if condition judgment; Then
Statment
Elif
Statment
Fi
Anti-quote: Returns the execution result of the command to the variable.
Set UserID
UserID = ' Id-u user1 '
command to end a script prematurely: exit: Exits the current process. is to exit the script
The end of any program has an execution status result and execution result. If get is the state result of the command
Exit to define the execution status results of the script.
Exit 0~255,0 is correct, 1~255 is error.
! Represent non, take counter action
if! grep ' ^work\> '/etc/passwd &>/dev/null; Then
echo "User does not exist"
Fi
Integer test:
-GT: Greater Than
-eq: Equals
-LT: Less than
-ne: Not equal to
-ge: greater than or equal to
-le: Less than or equal to
File test:
-E: Whether the file exists
-F: Test whether the file is a normal file
-D: Tests whether the specified path is a directory
-R: Tests whether the specified file is readable to the current user
-W: Tests whether the specified file is writable for the current user
-X: Tests whether the specified file is executable for the current user
This article is from the Linux learning blog, so be sure to keep this source http://884482.blog.51cto.com/874482/1697174
Bash Shell Foundation II conditional judgment