A regular expression
1. Here we will not detail the functions of various metacharacters in Regular Expressions
Let's just talk about a small problem I encountered in reading this chapter.
* Match the first character multiple times (including zero times)
For example, "1133 *", it should be clearly written as "113 (3 *)"
It can be understood that it matches 113 (0 3) 1133 (1 3), but why?
Match 111312?
111312 because it is matched in this way, a 3 is matched, and no matching is performed.
To match the beginning and end, you must change it to "^ 1133 * $ ",
In this case, you can only match the case where the name starts with 113 and n (n> = 0) is followed by 3.
Two-way Configuration
The following introduces another concept: wildcard. This is a concept that is easily confused with regular expressions.
Bash does not have the regular expression function in this province. In scripts, commands and software packages use regular expressions.
For example, sed, grep, and awk, they can interpret regular expressions.
When Bash is done, expand the file name extension-this is the so-called globbing-it is not a standard
Regular Expression. Instead, use wildcards. Wildcard interpretation of standard wildcards * And ?, Characters enclosed in square brackets,
There are other special characters (for example, ^ represents the anti-matching, but ^ matches the beginning of a row in the regular expression.
Note the differences between [^ B-d] And ^ [B-d] in regular expressions. The former indicates matching characters other than B, C, and D, and the latter indicates
Starting with B, C, D ). However, the wildcard matching mechanism has many limitations. Strings containing the asterisk (*) will not match.
Files starting with a card.
Trisubshell
1. External commands can generate a sub-process, but the built-in commands are not, so the built-in Bright is more efficient than the external command execution.
2. (command1, command2,...) a column of commands embedded in parentheses is run in a sub-shell and in the sub-shell
The variable with your performance cannot be used by this sub-shellCodeBlock. Only after some variables of the export,
The sub-process of the sub-shell can be accessed. The command running in {...} does not generate a sub-shell and runs in it.
3. Eg.
#! /Bin/bash
Show ()
{Var = 100}
(Var1. = 200)
Echo $ va $ var1 # result 100 null
Four-process replacement
1. Process replacement is similar to the command. Replace the command to assign the result of a command to a variable.
For example, Var = 'LS-l' or Var = $ (LS-l), process replacement is to return the output of one process to another process,
That is, sending the result of one command to another is a bit of a pipeline.
<(Command),> (command)
It is worth noting that there is no space between <,> and.