Linux-shell test, linux-shell
Nature of testing:
Is an operation command
According to $? Return Value to determine whether the condition is true
Operation Specifications:
Format 1: test Condition expression
Format 2: [conditional expressions]
Contact Method for test operation:
Direct root & echo YES judgment result
Usage: [conditional expression] & echo YES
Test example:
[-D "/etc/fstab"] & echo YES
[-D "/boot/fstab"] & echo YES
[-F "/etc/fstab"] & echo YES
[-F "/boot"] & echo YES
Existence and identification:
-E: whether the target exists
-D: whether it is a directory
-F: whether it is a file
Permission Detection:
-R: whether the read permission exists.
-W: whether write permission exists
-X indicates whether the execution permission is exclusive.
Integer comparison:
-Equal = (equal)
-Ne is not equal to (not equal)
-Gt greater than (greater)
-Lt is less than (lesser)
-Ge is greater than or equal to (greater or equal)
-Le is less than or equal to (lesser or equal)
Integer comparison:
[$ (Who | wc-l)-eq 2] & echo YES
[$ USER = "root"] & echo YES