1.1 How to use a file to test an expression
When we need to process an object in programming, we need to test the object and only take action to meet the requirements. The benefit of this is to avoid program errors and to consume system resources without fear, which can be files, strings, numbers, and so on.
The following table is the common file operator
Special NOTE: These operators for [[]], [], test almost universal more operations can be viewed with the man test. The above table of the-e as long as there is a file on the line whether it is a file or directory, the popular saying is that some people find a girlfriend, is a woman on the line not picky eaters. hehe ~
1.2 File Test expression Example 1.2.1 Normal file (test file type)
1.2.2 Directory file (test file type)
1.2.3 Test File properties
1.2.4 Test Shell Variable Example
Special Example: If the variable is not double-quoted, the test result may be incorrect
1.3 Production environment system conditions test Content for NFS startup scripts
You can view the condition test content under/etc/init.d/rpcbind, which is not listed here. Learn the Shell programming multi-system script.
1.4 Most efficient examples of file judgments
When doing test judgment, it is not necessary to follow the previous method, directly using the latter to make Test judgment advantage more concise such as:
1.5 file test expression judgment condition after executing multiple command statement cases
Usage:
[Conditional]&&{
Command 1
Command 2
Command 3
.........
}
Example:
It is also possible to write multiple commands in a single line, separated by semicolons.
Shell Script Programming Learning notes-file test expressions