Regular expression is a kind of requirement to deal with a lot of complicated data, to do fast searching, fast matching, fast substitution and deletion. Common regular expression commands have Grep,sed,awk (Three Musketeers) vi,egrep. The extended regular expressions are also supported by Egrep and awk.
Let's take a look at these commands. VI and VIM are introduced later.
Grep:
-V: Excludes matching content.
-I: Ignore case.
-O: Outputs only matching content.
-N: The line number is displayed at the beginning.
-e: Extended Regular Expression (=EGREP).
--color=auto: Supports color.
SED: Outputs both the matching content and the output of the source content intact.
S: Replace. (Format S/source string/replace string/)
G: Global. Generally used with S. (S/source string/replace string/g)
P: Print. Can be used with SG (S/source string/replace STRING/GP)
W File: Save to file.
D: Delete.
A: Append.
I: Insert in front.
C: Modify.
Y: Convert by character.
-F Script-file: Use Script-file to run file files. (Format: sed-f sed.sh test.txt)
-N: Silent mode output. (Output only matching content)
-I: Modify the source file.
-R: Supports extended regular.
Regular expression technology:
. : any single character.
*: matches the preceding character 0 or more times.
. *: Matches any number of characters.
[]: matches any single character within [].
^: Matches the beginning of the string.
$: Matches the line end of a string.
^$: Blank line.
\{m,n\}: Matches the previous character repeats m-n times.
\{m,\}: Matches the preceding character repeat at least m times.
\{,n\}: Matches the preceding character repeats up to n times.
Where \{\} uses {} for an extended regular expression.
\ (string\) and \ n: \ n (using \1,\2...\9) is the content of string.
An extended regular expression:
+: Repeat the previous character once in a shipment multiple times.
? : Repeats the preceding character 0 or one time.
| : matches the preceding or following character.
(): Matches the regular collection.
{M,n}: Repeats the previous character m-n times.
Posix:[] The character set within:
[: Alpha:] letter [: blank:] space or Tab character
[:d Igit:] Number [: Upper:] Uppercase
[:p UNCT:] punctuation [: lower:] lowercase letters
[: Space:] Blank character [: Alnum:] Letter or numeric character
Some commands for Linux regular expressions and regular expressions