The test command is a tool for testing conditional expressions in the shell for conditional judgments.
Grammar
Test (option)if [(option)]
File test
-b< File > Block: True if the file is a block special file;
-c< File > Character: True if the file is a character special file;
-s< File > Socker: True if the file is a special file for a socket;
-p< File > Pipeline: True if the file is a named pipe;
-f< files > file: True if the file is a normal file;
-d< File > directory: True if the file is a directory;
-e< file > exist: True if the file exists;
-g< File > Group: True if the file exists and is owned by the group;
-o< File > Own: True if the file exists and is owned by the user;
-g< File > SGID: True if the SGID bit of the file is set;
-u< File > SUID: True if the SUID bit of the file is set;
-k< file > Sticky bit: True if the file's sticky bit is set;
-r< File > read: True if the file is readable;
-w< File > Write: True if the file is writable;
-x< File > Execute: True if the file is executable.
-s< File > Size: True if the length of the file is not zero;
Integer test
-eq (equal): Tests whether two integers are equal;-ne (Not equal): Tests whether two integers are unequal;-GT (great than): test whether one number is greater than the other;-LT (less than): Test a The number is less than the other number;-ge (Great and Equal): greater than or equal to-le (less and equal): smaller or equal
Linux command--test test condition expression