Test method: Expression: expressed, expressed
[Expression]
[[Expression]]
Test expression
There are three common conditions tested in bash:
1. Integer test:
-eq equals
-lt less than
-ne Not equal to
-GT Greater than
-le less than or equal to
-ge greater than or equal to
Integer: Integers
integer1=63 integer2=77
[$INTEGER 1-eq $INTEGER 2]
[[$INTEGER 1-eq $INTEGER 2]]
Test $INTEGER 1-eq $INTEGER 2
2. File test:
-e file: Test files exist
-F File: Test files are normal files
-D File: Tests whether the specified path is a directory
-R File: Tests whether the current user has Read permission to the specified file
- W File: Tests whether the current user has write access to the specified file
-X file: Tests whether the current user has execute permission on the specified file
[-E File] tests for the existence of file files
[[-E file]] tests for the existence of file files
Test the script for syntax errors:
Bash-n Script
Bash-x script: Stepping through a script
3. String Test:
This article is from the "Learn Linux history" blog, please be sure to keep this source http://woyaoxuelinux.blog.51cto.com/5663865/1863899
Common condition tests for bash in Linux commands: integer test eq, file Test-E, string test = =