1) Judgment expression
IfTest (expression is true)
IfTest! expression is False
Test expression 1–a expression 22 expressions are true
Test expression 1–o Expression 22 expressions have a true
2) Judging the string
Test–n string string is not zero in length
Test–z string string has a length of zero
Test string 1 = string 2 string equal
Test string 1! = String 2 String unequal
3) Judging integers
Test integer 1–eq integer 2 integer equal
Test integer 1–ge integer 2 integer 1 greater than or equal to integer 2
Test integer 1–gt integer 2 integer 1 greater than integer 2
Test integer 1–le integer 2 integer 1 less than or equal to integer 2
Test integer 1–lt integer 2 integer 1 less than integer 2
Test integer 1–ne integer 2 integer 1 not equal to Integer 2
4) Judgment document
Test File1–ef File2 Two files with the same device number and I node number
Test file1–nt File2 file 1 newer than file 2
Test File1–ot File2 file 1 older than file 2
Test–b file files exist and are block device files
Test–c file files exist and are character device files
Test–d file files exist and are directories
Test–e file files exist
test–f file files exist and are regular files
Test–g file exists and the group ID is set
Test–g file files exist and belong to valid group ID
Test–h file exists and is a symbolic link (same-l)
Test–k file files exist and sticky bits are set
Test–b file files exist and are block device files
Test–l file exists and is a symbolic link (same-h)
Test–o file files exist and belong to valid user ID
Test–p file exists and is a named pipe
Test–r file files exist and are readable
Test–s file exists and is a socket
test –t fd The file descriptor is a that is opened at a terminal;
test –u file The file exists and sets its Set-user-id bit
test –w file The file exists and is writable
< Span class= "Hilite2" >< Span class= "Hilite2" >< Span class= "Hilite2" >< Span class= "Hilite2" >
test –x File file exists and executable
Linux Shell Test keyword