-e Whether the “Document” exists (commonly used)
-f whether the “Document” exists and is a file (commonly used)
-d whether this “document” exists and is a directory (commonly used)
-b Whether the Document exists and is a Block Device
-c Whether this Document exists and is a Character Device
-s whether this “document” exists and is a Socket file
-p Whether the “Document” exists and is a FIFO (PIPE) file
-l Whether the Document exists and is a link file
p>
-r checks if the document exists and has “readable” permissions
-w checks if the document exists and has the permission to be writable
-x checks if the document exists and has “executable” permissions
-u checks if the document name exists and has the property “SUID”
-g checks if the document name exists and has the attribute “SGID”
-k checks if the document name exists and has a “Sticky bit” property
-s checks if the document exists and is a “non-blank file”
>
>
>
>
>
>
>
>
-nt (newer than) determines whether file1 is newer than file2
-ot (older than) determines whether file1 is older than file2
-ef determines whether file1 and file2 are the same file, which can be used to determine the hard link. The key is to determine if both files point to the same inode
4. About the comparison between two integers, for example test n1 -eq n2
-Eq equals two values.
-Ne is not equal.
-gt n1 is greater than n2 (greater than)
-lt n1 is less than n2 (less than)
-e e n1 is greater than or equal to n2 (greater than or equal)
-le n1 is less than or equal to n2.
5
The test-z string determines if the string is empty and returns true for empty
Test-n string determines that the string is not null and returns false for null
= test -r filename -a-x filename
= test -r filename -a-x filename
– A (and) is both true! Test-r file-a-x file = test-r file-a-x file = test-r file-a-x file = test-r file-a-x file = test-r file-a-x file = test-r file-a-x file = test-r file-a-x file
-O (OR) Either is true! Test-r file-o-x file = test-r file-o-x file = test-r file-o-x file = test-r file-o-x file = test-r file-o-x file = test-r file-o-x file = test-r file-o-x file
! Inverse state, such as test! -x file. Returns true if file does not have x
Read More:
- If elif writing method of shell script
- Solution to shell script invocation error during Xcode real machine test
- Solution to the error $’\ R’: command not found when executing shell script under Linux
- Linux shell loop in a line for while
- Condition judgment and error handling in ansible playbook (fail module failed_when changed_when keyword)
- Several methods of executing multiple commands in Linux shell
- Linux shell RM deletes all. O suffix files in the subdirectory
- The difference between single equal sign and double equal sign EQ in shell script
- Solution of adding judgment error in the iterative process of Java iterator iterator
- Linux’s method of clearing DNS cache and refreshing DNS in shell terminal (Ubuntu, Debian)
- Differences between shell script variable assignment and C language variable assignment
- An undetermined call to function ‘shell’: missing ‘. Stop. Problem encountered when using shell command in makefile
- Ngnix+gunicorn+Flag project deployment in Ubuntu
- Removing duplicate lines from Linux shell files
- Shell script syntax error near unexpected token ‘$’Do
- Solve the problem of shell script “syntax error near unexpected token `fi’”.
- Linux shell gets the file name under the folder
- Error in running script in openwrt
- Shell script execution error: “syntax error near unexpected token”
- Error BC: command not found when git bash runs shell script