The test command usage. Function: Check file and compare value 1) Judge the expression if test (expression is true) if test! expression is false test expression 1–a expression 22 expression is true test expression 1–o expression 22 expression has a true 2) determine string Test–n string The length of the string is not 0 test–z string string length is zero Test string 1 = string 2 string equal test string 1! = String 2 String unequal 3) determine integer test integer 1–eq integer 2 integer equal Test integer 1–ge integer 2 integer 1 greater than equals integer 2test integer 1–gt integer 2 integer 1 greater than integer 2test integer 1–le integer 2 integer 1 less than equals integer 2test Integer 1–lt integer 2 integer 1 less than integer 2test integer 1–ne integer 2 integer 1 not equal to Integer 2 4) determine file test File1–ef File2 two files have the same device number and I node number test file1–nt File2 file 1 than file 2 new Test File1–ot File2 file 1 is present in file 2 older Test–b file and is a block device file Test–c files exist and is a character device files test–d file file exists and is a directory test–e file file exists te The st–f file file exists and is a regular document Test–g file exists and is set up idtest–g file files exist and belong to valid group Idtest–h file exists and is a symbolic link (same-l) test–k file file exists and set the sticky bit test–b file exists and is a block device file Test–l file exists and is a symbolic link (with-h) test–o file exists and belongs to a valid user Idtest–p file file exists and is a named pipe T Est–r file files exist and are readable test–s file files exist and are a socket test–t FD file descriptor is open in a terminal Test–u file exists and set its Set-user-id bit test–w file file to save In and writable test–x file files exist and are executable
Use of the test command in shell syntax