What is regular
A regular expression is a way to describe characters or strings by combining symbols with special meanings (called regular expressions). Or, a regular is a rule that describes a class of things. There are regulars everywhere in life: for example, if we describe: four legs, you might think of an animal with four legs, or a table, chair, etc
In Linux, wildcards are interpreted by the shell, while regular expressions are interpreted by commands. Grep text processing command is used to interpret regex.
2 the grep
parameter
-n: show the line number. -o: show only the matched content. -q: silent mode, no output, use $? To determine whether the execution was successful, that is, whether the desired content was filtered
– l: If the match is successful, only the file name is printed. If the match fails, the file name is not printed. Generally, -rl is used together with grep -rl ‘root’ /etc -a: If the match is successful, the matching line and the last N lines are printed together. -c: if the match is successful, the matching line and the first N lines are printed together. –color -c: if the match is successful, the number of matched lines is printed. -e: egrep, extended -i: case is ignored
-v: the value is reversed but not matched. -w: matches a word. A word is a combination of Letters separated by special symbols.