grep Text Search Tool:
grep [options] pattern [file ...] --Pattern Mode: string, Regular expression
Matches the target text row by line , based on the user-specified pattern, and prints the line to which it matches .
Pattern Pattern: Filter conditions written by regular expression characters and text characters.
650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/21/e55b6e7bdc7f21adfe3f648f65aa965d.png-wh_500x0-wm_3 -wmp_4-s_1191339169.png "title=" Grep.png "alt=" E55b6e7bdc7f21adfe3f648f65aa965d.png-wh_ "/>
650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/21/ed090c480d0bc2b00f7897f6df3827fd.png-wh_500x0-wm_3 -wmp_4-s_2716848750.png "title=" Grep2.png "alt=" Ed090c480d0bc2b00f7897f6df3827fd.png-wh_ "/>
650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/21/ca20c9efeb2917eaa4d970fafeb35875.png-wh_500x0-wm_3 -wmp_4-s_1958472438.png "title=" Grep3.png "alt=" Ca20c9efeb2917eaa4d970fafeb35875.png-wh_ "/>
650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/21/afd113f292c8fbf1dd36bad42b87e733.png-wh_500x0-wm_3 -wmp_4-s_760694141.png "title=" Grep5.png "alt=" Afd113f292c8fbf1dd36bad42b87e733.png-wh_ "/>
#===============================
grep command Options
--color=auto: Coloring the text to match to a display
650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/21/3c2b73aef621b579db1d1ef55152a7aa.png-wh_500x0-wm_3 -wmp_4-s_3034866491.png "title=" Grep6.png "alt=" 3c2b73aef621b579db1d1ef55152a7aa.png-wh_ "/>
-V: Shows rows that are not matched by pattern--take counter
650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/21/39d5ead4bb7d70e639105d0eb744984d.png-wh_500x0-wm_3 -wmp_4-s_2332768294.png "title=" Grepv.png "alt=" 39d5ead4bb7d70e639105d0eb744984d.png-wh_ "/>
-I: Ignore character case
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/21/035ad193cfc658c8cf2ba505a72c2878.png-wh_500x0-wm_3 -wmp_4-s_1225696898.png "title=" Grepi.png "alt=" 035ad193cfc658c8cf2ba505a72c2878.png-wh_ "/>
-N: Show matching line numbers
650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/21/0c97fb3fced86dcf9beec52d490d2dc1.png-wh_500x0-wm_3 -wmp_4-s_528205160.png "title=" Grepn.png "alt=" 0c97fb3fced86dcf9beec52d490d2dc1.png-wh_ "/>
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/21/92fec6ea6ea256736792a2a82e426081.png-wh_500x0-wm_3 -wmp_4-s_264588994.png "title=" Grepn.png "alt=" 92fec6ea6ea256736792a2a82e426081.png-wh_ "/>
-C: Count the number of matching rows
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/21/de8ea2b262b63df11d9915f578677ea6.png-wh_500x0-wm_3 -wmp_4-s_1822599777.png "title=" Grepc.png "alt=" De8ea2b262b63df11d9915f578677ea6.png-wh_ "/>
-O: Show only the matched string/display the searched string
650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/21/6f713a25c62cf79c2992d60f4ab177e7.png-wh_500x0-wm_3 -wmp_4-s_1916737179.png "title=" Grepo.png "alt=" 6f713a25c62cf79c2992d60f4ab177e7.png-wh_ "/>
-Q: Silent mode, does not output any information-grep root/etc/passwd &>/dev/null
650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/21/0336d3fb58e884917c3e9b233769c810.png-wh_500x0-wm_3 -wmp_4-s_764512593.png "title=" Grepq.png "alt=" 0336d3fb58e884917c3e9b233769c810.png-wh_ "/>
-A #: After, # lines-Root after three lines
650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/21/1e8a8b4964db68cdd9a55c23682da39c.png-wh_500x0-wm_3 -wmp_4-s_3509915136.png "title=" Grepa.png "alt=" 1e8a8b4964db68cdd9a55c23682da39c.png-wh_ "/>
-B #: Before, Front # line
650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/21/1743672631453158a328a655eb12b07c.png-wh_500x0-wm_3 -wmp_4-s_3395720652.png "title=" Grepb.png "alt=" 1743672631453158a328a655eb12b07c.png-wh_ "/>
Small action: View the IP address that the company runs/occupies?
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/21/7308e019ea6cb837897f279c165596bb.png-wh_500x0-wm_3 -wmp_4-s_3516241056.png "title=" Grep7.png "alt=" 7308e019ea6cb837897f279c165596bb.png-wh_ "/>
-c #:context, front and back # lines
650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/21/3919d5938b91f1f6bc1fa38c53b66a16.png-wh_500x0-wm_3 -wmp_4-s_2685660174.png "title=" Grepc1.png "alt=" 3919d5938b91f1f6bc1fa38c53b66a16.png-wh_ "/>
-E: Implementing a logical or relationship between multiple options
650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/21/00dfa60698d480833e057a92b61af78f.png-wh_500x0-wm_3 -wmp_4-s_2016176890.png "title=" Grepe.png "alt=" 00dfa60698d480833e057a92b61af78f.png-wh_ "/>
Grep–e ' Cat '-e ' dog ' file
-and the relationship
650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/21/e2da5fd887072d8a059fe21f9d2ca073.png-wh_500x0-wm_3 -wmp_4-s_3869086046.png "title=" Grep8.png "alt=" E2da5fd887072d8a059fe21f9d2ca073.png-wh_ "/>
-W: Matches entire word
650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/21/2bff20fcd15c35ba26186829b817eef5.png-wh_500x0-wm_3 -wmp_4-s_808605252.png "title=" Grepw.png "alt=" 2bff20fcd15c35ba26186829b817eef5.png-wh_ "/>
-E: Use ere-f: Equivalent to Fgrep, does not support regular expressions
#=====================================
Meta-character classification: character matching, number of matches, position anchoring, grouping
------------------------------------------------------------------------
Basic regular Expression meta-characters
1) Character matching:
. Match any single character
650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/21/246f71d23051e97e67248c79cbd9059f.png-wh_500x0-wm_3 -wmp_4-s_2172815734.png "title=" Grep9.png "alt=" 246f71d23051e97e67248c79cbd9059f.png-wh_ "/>
[] matches any single character within the specified range
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/21/47e172d685dcf935a96e3e0e8d84701c.png-wh_500x0-wm_3 -wmp_4-s_3742969697.png "title=" Grep10.png "alt=" 47e172d685dcf935a96e3e0e8d84701c.png-wh_ "/>
[^] matches any single character outside the specified range
650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/21/cb938bf2458197118b23bdfcaf8c8b86.png-wh_500x0-wm_3 -wmp_4-s_844363137.png "title=" Grep11.png "alt=" Cb938bf2458197118b23bdfcaf8c8b86.png-wh_ "/>
[: Alnum:] Letters and numbers
650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/21/78fb4ff0df7900089ab8ca3656319475.png-wh_500x0-wm_3 -wmp_4-s_983754061.png "title=" Grep12.png "alt=" 78fb4ff0df7900089ab8ca3656319475.png-wh_ "/>
[: Alpha:] represents any English uppercase and lowercase characters, i.e. A-Z, A-Z
650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/21/de2a2cf9aa72a5abd18160a4e82c37c1.png-wh_500x0-wm_3 -wmp_4-s_2148827055.png "title=" Grep13.png "alt=" De2a2cf9aa72a5abd18160a4e82c37c1.png-wh_ "/>
[: Lower:] lowercase letter [: Upper:] Uppercase
650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/21/92e3b9900d417124603cef5ef27060fd.png-wh_500x0-wm_3 -wmp_4-s_4217060445.png "title=" Grep15.png "alt=" 92e3b9900d417124603cef5ef27060fd.png-wh_ "/>
[: Blank:] white space characters (spaces and tabs)
[: Space:] Horizontal and vertical white space characters (more than [: blank:] contains a wide range)
[: Cntrl:] non-printable control characters (backspace, delete, alarm ...) )
[:d igit:] decimal digits [: xdigit:] hexadecimal digits
[: Graph:] printable non-whitespace characters
[:p rint:] printable characters
[:p UNCT:] Punctuation
#===================================
What is the version number for version 6.9 and version 7.4? What if the version is 17?
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= " Https://s3.51cto.com/oss/201711/21/5315c5708ceb49347e7b5a0ad944728f.png-wh_500x0-wm_3-wmp_4-s_379034125.png " Title= "Grep16.png" alt= "5315c5708ceb49347e7b5a0ad944728f.png-wh_"/>
650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/21/1ac590185cc5b065c14384d32437d0fa.png-wh_500x0-wm_3 -wmp_4-s_2276332298.png "title=" Grep30.png "alt=" 1ac590185cc5b065c14384d32437d0fa.png-wh_ "/>
#======================================
Number of matches: used after the number of characters to be specified, to specify the number of occurrences of the preceding character
* match the preceding characters any time, including 0 greedy modes: match as long as possible
650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/21/603feb6246526c17757cef74fd77e22e.png-wh_500x0-wm_3 -wmp_4-s_3849186170.png "title=" Grep17.png "alt=" 603feb6246526c17757cef74fd77e22e.png-wh_ "/>
. * Any character of any length --remember: Any character starting with r any length
650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/21/cd602ab58cbb51bf42facc80bc5c5332.png-wh_500x0-wm_3 -wmp_4-s_2196475503.png "title=" Grep18.png "alt=" Cd602ab58cbb51bf42facc80bc5c5332.png-wh_ "/>
A * Access file name as a wildcard | "A *" ' A * ' is caused by a regular.
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/21/6a7de1e816573ecdbecfec628d221565.png-wh_500x0-wm_3 -wmp_4-s_2181566777.png "title=" Grep19.png "alt=" 6a7de1e816573ecdbecfec628d221565.png-wh_ "/>
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/21/0ef11a836207bdb6fc9023a99a3bb77e.png-wh_500x0-wm_3 -wmp_4-s_2763164923.png "title=" Grep20.png "alt=" 0ef11a836207bdb6fc9023a99a3bb77e.png-wh_ "/>
Summary: grep * anaconda-ks.cfg default as a wildcard search for what? A * and anaconda-ks.cfg
is a start, if it is b* other will search anaconda-ks.cfg text, insurance, or add
"" ' Of course it doesn't matter if you use/root/anaconda-ks.cfg. | Add the quotes.
650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/21/3fb814d972908afa833d23abda4b0a02.png-wh_500x0-wm_3 -wmp_4-s_2986040035.png "title=" Grep21.png "alt=" 3fb814d972908afa833d23abda4b0a02.png-wh_ "/>
Match the preceding characters 0 or 1 times------ -----the wireless loop matches multiple times
650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/21/a94cc9cbc14edf3ce1bb2554cad0dea5.png-wh_500x0-wm_3 -wmp_4-s_3973775724.png "title=" Grep22.png "alt=" A94cc9cbc14edf3ce1bb2554cad0dea5.png-wh_ "/>
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/21/5b796ed83dae455ac38ca37520324556.png-wh_500x0-wm_3 -wmp_4-s_2196380628.png "title=" Grep23.png "alt=" 5b796ed83dae455ac38ca37520324556.png-wh_ "/>
\+ matches the characters in front of it at least 1 times
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/21/6ffc2f398f14aac07613d89fd913489d.png-wh_500x0-wm_3 -wmp_4-s_1195655326.png "title=" Grep25.png "alt=" 6ffc2f398f14aac07613d89fd913489d.png-wh_ "/>
\{n\} matches the preceding character n times
650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/21/c908e0b91f5a52f4d6b5a7c967c95d21.png-wh_500x0-wm_3 -wmp_4-s_3252180278.png "title=" Grep26.png "alt=" C908e0b91f5a52f4d6b5a7c967c95d21.png-wh_ "/>
\{m,n\} matches the preceding character at least m times, up to N times | Match multiple times
650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/21/c0baa57b1add59de3a4524e8028709dc.png-wh_500x0-wm_3 -wmp_4-s_2882499046.png "title=" Grep27.png "alt=" C0baa57b1add59de3a4524e8028709dc.png-wh_ "/>
\{,n\} matches the preceding character up to n times |0-5 0-5 .... Multiple matches
650) this.width=650; "Src=" Https://s4.51cto.com/oss/201711/21/916caa8a24f322fa36ee64ba16b91a2d.png-wh_500x0-wm_3 -wmp_4-s_680372718.png "title=" Grep28.png "alt=" 916caa8a24f322fa36ee64ba16b91a2d.png-wh_ "/>
\{n,\} matches the preceding character at least n times
650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/21/1d6a9d5ce520489fd593d0184920ca74.png-wh_500x0-wm_3 -wmp_4-s_3151163128.png "title=" Grep29.png "alt=" 1d6a9d5ce520489fd593d0184920ca74.png-wh_ "/>
#===============================================
Position anchoring: positioning where it appears
^ Beginning of the line anchor, for the leftmost mode
$ line End anchor for the right side of the pattern
^pattern$ for pattern matching entire row
^$ Empty Line
^[[:space:]]*$ Blank Line
\< or \b The first anchor for the left side of the word pattern
\> or \b ending anchor; for the right side of the word pattern
\<pattern\> Match Whole Word
This article from "Linux-mylog" blog, declined reprint!
Linux Text Processing tool 2-grep