One. Eval command
Syntax: eval cmdline
Eval will scan the back of the CmdLine two times, if CmdLine is a normal command after the first scan, execute this command, and if the cmdline contains indirect references to variables, the semantics of the indirect references are guaranteed.
For example:
In order to output the last parameter there are the following programs:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/83/A0/wKioL1d42YKjtMXdAAAaAUgUAvU856.png "title=" Shell6.png "alt=" Wkiol1d42ykjtmxdaaaaauguavu856.png "/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/83/A1/wKiom1d42ZSDwtfpAAAdP0d8reA575.png "title=" Shell5.png "alt=" Wkiom1d42zsdwtfpaaadp0d8rea575.png "/>
Where Echo $4 is known to have a total of 4 number of cases, the direct output of the 4th; When you do not know the total number of cases to try to use the echo "\$$#" Output the last number, the result does not achieve the desired result, and the eval echo "\$$#" The last number can be found without knowing the total.
Two. single brackets [] and double brackets [[]]
(1) Single brackets []
1.[] is used for conditional testing, is a command,] to turn off conditional judgment, this command takes its arguments as a comparison expression or a file parameter, and returns an exit status code based on the result of the comparison. If True then the exit code is 0, and the exit code is 1 if False.
The comparison operators available in [] are only = = and! =, both are used for string comparisons and cannot be used for integer comparisons. Integer comparisons can only use-GT (greater than).-LT (less than).-eq (equals).-ge (greater than or equal).-le (less than equals) to compare.
When comparing strings, be careful to add the same characters to both sides of the comparison operator, so that you can compare them when the input is empty. At the same time, the [and] and intermediate expressions must have spaces, and the comparison operators and expressions should also be preceded by spaces. The procedure is as follows:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/83/A1/wKioL1d5Cs2zvDyOAABDp4Rs_aA666.png "title=" Shell7.png "alt=" Wkiol1d5cs2zvdyoaabdp4rs_aa666.png "/>
Execution Result:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/83/A3/wKiom1d5Ct-xY1LSAAAajwcYzbU714.png "title=" Shell8.png "alt=" Wkiom1d5ct-xy1lsaaaajwcyzbu714.png "/>
2.[] can be used as part of a regular expression to describe a matching range of characters;
3. In the context of an array structure, [] is used to refer to the number of each element in the array.
(2) Double brackets [[]]
1.[[]] is not a command, it is a keyword. [[]] is more general than [] structure, all characters between [[and]] do not have filename extension or word segmentation, but parameter extension or command substitution occurs.
2. Use [[]] conditions to determine the structure, to prevent many logic errors in the script. For example, the &&,| |,< and > Operators can normally exist in the [[]] Conditional judgment structure ([[]] does not support ">=" and "<="), if it appears in [] will be an error (in [] when you want to do with, or judgment, need to use a ( and -O (or) to connect).
The procedure is as follows:
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/83/A2/wKioL1d5FnzictFfAABudLcc_9c733.png "title=" Shell0.png "alt=" Wkiol1d5fnzictffaabudlcc_9c733.png "/>
Execution Result:
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/83/A2/wKioL1d5FpKgGeFBAABpK9-3q2c531.png "title=" Shell9.png "alt=" Wkiol1d5fpkggefbaabpk9-3q2c531.png "/>
This article is from the "Zwy" blog, make sure to keep this source http://10548195.blog.51cto.com/10538195/1795398
eval command. Single brackets [] and double brackets [[]]