Shell string interception, shell string Interception
1. The variable var starts from the npos in [0, length-1] bits, and truncates num characters from the left to the right:
$ {Var: npos: num}
Conclusion: If npos <0, the result is the original var value;
If npos> length (var)-1, the result is an empty string;
If the actual number of characters is less than num, the return value is based on the actual number of characters.
2. The variable var is truncated forward/backward Based on the specified string {first appearance, last appearance:
$ {Var ### * string} # extract from left to right and the last string
$ {Var # * string} # extract from left to right and the first string
$ {Var % string *} # extract from right-> left and the last string
$ {Var % string *} # extract from right-> left and the first string
Summary: For the # truncation character, the wildcard * is on the left side of the string and is intercepted from left to right;
For the % truncation character, the wildcard * is on the right of the string and is intercepted from the right to the left;
A single truncation character indicates the first occurrence position, and a double truncation character indicates the last occurrence position.
3. If you have time, summarize other methods ......