Regular expression:
It is the method of processing strings. The processing of strings is performed in units of behavior. With the help of some special symbols, users can easily search/replace a specific string.
For example, to query the keywords in a file: grep 'mail' /etc/rc.d/*
last | grep root : pipe command
grep -n 'the' jason.txt : -n means output line number
Any single character (.) and repeated characters (*)
grep -n 'g..d' jason.txt
When searching for strings with at least two oos, you need ooo*, that is, grep -n 'ooo*' jason.txt
Special characters for basic regular expressions
^word: The string to be searched is at the beginning of the line Example: grep -n '^#' jason.txt The beginning of the line is listed with #
word$: end of line Example: grep -n '!$' jason.txt
*: Repeat 0 or more of the previous character
[]: The symbol of repeated special characters of the character set grep -n 'g[ld]' jason.txt Search for gl or gd