Test condition judgment
# symbol [] equals test command
Ten 5 # Judging the size of echo $? # View the previous sentence The test command returns the status "hello" # To determine if the string length is 0[$ 0"success" | | Exit # To determine the success hint, fail to exit
Expression is a string operation
-N STR # string str is not empty-Z str # string str is empty
Expression for file operation
-A # and, two conditions are true-B # whether the block file -P # file is a named pipe-C # Whether the character file- r # file is readable-D # whether a directory -S # Whether the length of the file is not zero-e # The file exists if- s # is a socket file-F # whether the normal file- x # file is executable or true-G # Whether to set the file's SGID bit-u # If the file's SUID bit-G # File exists and is owned by the group All-W # file is writable, then true-K # file is set paste bit- t fd
# FD is an open file descriptor that is connected to the terminal (FD defaults to 1)-O # or, a condition is true-o # file exists and is owned by the user! # Take the reverse
Expression is an integer operation
Expr1-a EXPR2 # If the EXPR1 and EXPR2 evaluates to True, then true Expr1-o expr2 # True if EXPR1 or EXPR2 evaluates to True
Two-value comparison
integer string -lt < # less than -gt > # greater than -le <= # Less than or equal to-ge >= # is greater than or equal to-eq = = # equals -ne! = # does not equal
Shell Test condition judgment