Function of the test command: check files and compare values.
1. judgment Expression
If test (expression true)
If test! (Expression is false)
Test expression 1-
Expression 2: both expressions are true.
Test expression 1-o
Expression 2: either of the two expressions is true.
2,
The length of the test-n string is non-zero.
The length of the test-z string is zero.
Test string 1 = string 2
Equal strings
Test string 1! = String 2
Character String
3. Judge integer
Test integer 1-ep integer 2 integer equal
Test integer 1-ge integer 2 integer 1 is greater than or equal to integer 2
Test integer 1-gt integer 2 integer 1 is 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 is not equal to integer 2
4. File judgment
Test File1-ef File2 two files have the same device number and node number
Test File1-nt File2 file 1 is newer than file 2
Test File1-ot File2 file 1 is older than file 2
The test-B File exists and is a block device File.
The test-c File exists and is a character device File.
The test-d File exists and is a directory.
The test-e File exists.
The test-f File exists and is a regular File.
The test-g File exists and the group ID is set.
The test-G File exists and belongs to the valid group ID.
The test-h File exists and is a symbolic link (same as-L)
The test-k File exists and the sticky bit is set.
The test-B File exists and is a block device File.
The test-L File exists and is a symbolic link (same as-h)
The test-o File exists and is a valid user ID.
The test-p File exists and is a named pipe.
The test-r File exists and is readable.
The test-s File exists and is a socket.
The test-t FD file descriptor is opened on a terminal.
The test-u File exists and its set-user-id bit is set.
The test-w File exists and can be written.
The tes-x File exists and can be executed.
Z
From song_0521