First, mathematical operations
1. Expr command
This command can perform mathematical operations on the command line.
650) this.width=650; "title=" 1451372345836139.jpg "alt=" 8.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151229/1451372345836139.jpg "/>
This command is not recommended because it is too cumbersome to use.
2. square brackets and double parenthesis
$[EXPRESSION]
$ ((EXPRESSION))
Expressions with square brackets already appear in the previous instance: $[$a + $b].
3. Let command
650) this.width=650; "title=" 1451409506598232.jpg "alt=" 12.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151230/1451409506598232.jpg "/>
4. Arithmetic Operators
X+=y: Equivalent to X=x+y
X-=y: Equivalent to X=x-y
X*=y: Equivalent to X=x*y
X/=y: Equivalent to x=x/y
x + +: equivalent to X=x+1
x--: Equivalent to X=x-1
Second, string connection
The variable name is added {} When the variable is referenced directly to the string.
650) this.width=650; "title=" 1451410084162674.jpg "alt=" 1.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151230/1451410084162674.jpg "/>
Third, condition test
The expression for a conditional test can use the following three formats:
[Expression]: Note that there is a space between the brackets and the expression;
[[Expression]]: note there is a space between the brackets and the expression;
Test expression: The above two formats are actually the other formats of the test command.
The test command can perform 3 types of conditional judgments: integer test, String test, and file test.
1. Integer Test
-EQ: Tests whether two integers are equal;
-ne: Test whether two integers are unequal, unequal to true, and equal to false;
-GT: Test whether a number is greater than a number, greater than true, otherwise false;
-LT: Test whether a number is less than one number, less than true, otherwise false;
-ge: Test whether a number is greater than one number, greater than or equal to true, otherwise false;
-le: Test whether a number is greater than one number, less than or equal to true, otherwise false;
Example: "Equal" is displayed if two parameters are equal, otherwise "different" is displayed.
650) this.width=650; "title=" 1451532839506753.jpg "alt=" 1.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451532839506753.jpg "/>
2. Character Test
= =: The test is equal, and so is true, not equal to false;
! =: Test Whether it is unequal, not equal to true, etc for false;
=~: Mode configuration;
-Z String: Tests whether the specified string is empty or null for true
-N String: Tests whether the specified string is empty and empty is true
-S string: Tests whether the specified string is not empty, is not empty, and the null is False
Instance:
650) this.width=650; "title=" 1451534594896602.jpg "alt=" 2.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451534594896602.jpg "/>
650) this.width=650; "title=" 1451534949299305.jpg "alt=" 3.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451534949299305.jpg "/>
Above is an example of using "-Z", if you change to-N, as shown:
650) this.width=650; "title=" 1451535102868118.jpg "alt=" 4.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451535102868118.jpg "/>
Note: It is best to add quotation marks when comparing variables (single and double), otherwise if the variable is empty, an error will be given.
3. File Test
-A file: Test file exists as true, otherwise false;
-E File: Tests if file exists, exists as true, otherwise false;
-l/-l file: soft link files;
-B: block equipment;
-C: Character device;
-S: Socket file;
-P: Named pipes;
-S: Non-empty files are true;
-F File: Tests whether the file is a normal document;
-D FILE: Tests whether the specified path is a directory;
-R file: whether the test files are readable to the current user;
-W File: Whether the test file is writable to the current user;
-X file: Tests whether the file is executable to the current user;
-N File: The modification of the file time is more true than the new access time;
Content is redirected to a file, but the file has not been opened
File1-nt file2:file1 than File2 new is true;
File1-ot File2:file1 is more true than the old file2.
Example: If/test is present, rename it to/new-test, otherwise create this directory:
650) this.width=650; "title=" 1451541446858176.jpg "alt=" 5.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451541446858176.jpg "/>
Example: Given a parameter, first determine whether this parameter exists, if there is a decision whether the file, if the file to ensure that it has execute permissions:
650) this.width=650; "title=" 1451548262885035.jpg "alt=" 6.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451548262885035.jpg "/>
Verify:
650) this.width=650; "title=" 1451548445249868.jpg "alt=" 7.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451548445249868.jpg "/>
4. Combination test conditions
Implementing logical operations between multiple conditions
-A: With relation [condition1-a Condition2]
-O: or relationship [Condition1-o Condition2]
!: Non-relationship [! condition] or [-not condition]
650) this.width=650; "title=" 1451549270575905.jpg "alt=" 8.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451549270575905.jpg "/>
650) this.width=650; "title=" 1451549602131066.jpg "alt=" 9.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451549602131066.jpg "/>
Iv. the logical relationship between commands
&&: Logical AND, the right statement is executed only if the condition on the left is true;
|| : Logical OR, the right statement executes when the left condition is false.
The above example can also be done using logic and:
650) this.width=650; "title=" 1451549834678226.jpg "alt=" 10.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451549834678226.jpg "/>
650) this.width=650; "title=" 1451550143346319.jpg "alt=" 10.jpg "src=" http://www.178linux.com/ueditor/php/upload/ Image/20151231/1451550143346319.jpg "/>
Operation of shell script programming