Linux grep command notes and linuxgrep command notes
Grep
-I is case insensitive.
-- Color add color
Alias grep = grep 'grep -- color
-V: displays the rows not matched by the pattern.
-O only displays the strings matched by the pattern
Review:
* Any character of any length
? Any single character
[] Within the specified range
[^] Out of the specified range
Regular EXPression: Regular EXPression, (REGEXP)
Metacharacters:
. Match any single character
* Match any character before it (Greedy Mode)
.*
? Match the first character once or 0 times (\)
\ {M, n \} matches the first character at least m times, n times
Example: \ {1, \ }\{, 3 \}
^ Pin the beginning of a line
$ Pin the end of a row
^ $ Blank line
[] Matching any single character in a specified range
[^] Match any single character out of the specified range
[: Digit:] Number
[: Lower:] lowercase letters
[: Upper:] uppercase letters
[: Punct:] punctuation marks
[: Space:] blank characters
\ <Or \ B anchor specifies the beginning of a word. Any character after it must appear as the first word.
\> Or \ B anchor determines the end of the word. Any character before it must appear as the end of the word.
Example: \ <root \>
\ (\) Group
Example: \ (AB \)*
\ 1 reference the first left brace and the content in the corresponding right Brace
Example: \ (l. e \). * \ 1