Analyzing test conditions

Analyzing test conditions

1  # symbol [] is equivalent test command
 2   
. 3  expression The string of operations {
 . 4   
. 5      - n-str # if not empty string str
 . 6      the -Z # string str str is empty

 

expression as file operations

. 1 - A # and, two conditions are true
 2 - B # whether the file block     
 . 3 - P # whether a file is a named pipe
 . 4 - C # whether the character file   
 . 5 - R & lt # file is readable
 . 6 - D if a directory #   
 7 - the length of the file is the s # not zero
 . 8 - whether e # file exists   
 . 9 - S # whether the socket file
 10 - F # whether normal files   
 . 11 - X is executable file # true
 12 is - G # whether a file SGID bits 
 13 - U # whether a file SUID bit
 14 -G # whether the file exists and all belong to the group of 
 15 - W      # file is writable, True
 16 - if the file has k # sticky bit  
 . 17 -t # FD and FD whether the terminal is connected to the open file descriptor (fd default . 1 )
 18 is - O # or, a condition is true
 . 19 - O # file exists and all owned by the user
 20 ! # negated

 

 

expression is an integer operation

. 1 expr1 - A If expr2 # expr1 and expr2 evaluates to true True
 2 expr1 -o expr2 # expr2 if expr1 evaluates to true or True

 

 

Compare two values

An  integer string
 2 -LT-<          # less than
 . 3 -gt>          # greater than
 . 4 -le <=         # or less
 . 5 -ge> =         # or greater
 . 6 -eq ==         # equal
 . 7 -ne! =         # Is not equal to
 8  
. 9  
10  
. 11 test 10 -LT- . 5        # size determination
 12 is  echo $?              # View status command returns the sentence test results # 0 is true, a false
 13 is test -n " Hello "      # string length is determined whether 0
 14 [$ ? -eq0 ] && echo  " Success " || Exit # judge success tips, fails to exit

 

Guess you like

Origin www.cnblogs.com/alog9/p/11532669.html