What is grep
grep (Global search REgular expression and Printout the line), which is a globally searchable regular expression and prints out matching rows, is a powerful text-search tool in the Linux system that is based on user-specified "patterns ( pattern) "Filters the target text to show rows that are matched by the pattern.
Basic syntax format for grep commands
grep [Options] PATTERN [FILE ...]
Common options for grep
-V: Reverse the matching content
-O: Show only what matches to
-I: Ignore case
-N: Show line numbers
--color=auto: Using colors to display matching content
The basic usage of grep in conjunction with regular expressions
.: Any single character
[]: Any single character of the characters contained in parentheses, such as
Pure numbers: [[:d Igit:]] or [0-9]
lowercase letters: [[: Lower:]] or [A-z]
Capital letters: [[: Upper:]] or [A-z]
Uppercase and lowercase letters: [[: Alpha:]] or [a-za-z]
Numbers plus letters: [[: Alnum:]] or [0-9a-za-z]
whitespace characters: [[: Space:]]
Punctuation: [[:p UNCT:]]
Linux grep command usage and regular expressions