The shell condition test can be done in two ways:
Test parameters Testing Content
[Parameter test content]
First, test file type:
TEST-E file name (test file exists)
[-e FileName] Test file exists, note the space on both sides of the bracket
Test-f file name to determine if it is normal
test-d file name to determine whether it is a directory
Test-b file name to determine if block device files
TEST-C file name to determine if the character device files
Second, test file permissions:
Test-r file name to determine whether or not to read permissions
TEST-W filename to determine whether the file and write permission
Test-x filename to determine if the file has Execute permission
Test-s file name to determine whether files are non-blank, content is true
Comparison of three, two files:
[File1-nt File2] file1 is newer than file2
[File1-ot File2] file1 is older than file2
[File1-et File2] Fie1 and file2 are linked files
Four, two arrays between the judgment:
[N1 EQ N2] N1 and N2 are equal
[N1 NE n2] N1 and N2 are not equal
[N1 GT N2] N1 is greater than N2
[N1 LT N2] N1 is less than N2
[N1 GE N2] N1 greater than or equal to N2
[N1 le N2] N1 is less than or equal to N2
Five, string judgment:
[-Z string] Determines whether the string is empty
[String 1 = = String 2] Determine if string 1 equals string 2
[String 1!] = string 2] Determine if string 1 is not equal to string 2
Shell condition Test