First, grep, egrep, Fgrep command
In this paper, we mainly introduce the basic parameters and usage formats and methods of the Egrep fgrep commands and regular expressions under the Linux system. (Note: The FG represents an example in the text)
1.1, the basic definition:
grep (Global search regular RE) and print out of the line, a comprehensive search for regular expressions and print out rows) is a powerful text search tool that can only use basic regular expressions to search for text and print matching rows.
grep is a very common and often used command whose main function is to compare string data and then print the strings that match the needs of the user, but the idea is that grep searches for a string in the data, which is filtered in whole rows.
The Egrep command is equivalent to GREP-E, which enables you to use extended regular expressions to search for text and print strings that match the user's needs.
The Fgrep command is equivalent to Grep-f, which uses a fixed string to search for text, but does not support regular expression references, so this command executes the fastest.
1.2. Basic usage of command
grep [option] ' Search string ' filename
grep Common options:
-A: Searching for data in a binary file as a text file
FG: Search for rows containing RC strings within/etc/inittab
Grep-a ' RC '/etc/inittab
-C: Calculates the number of ' search strings ' found
-I: Ignore case
-V: Reverse lookup, which shows the line without the ' search string ' content
-O: Displays only strings matched by pattern
-N: Output line number
--colour (color): Colors display
-A: Displays the following n lines that match to the character Funa
-B: Show the front n rows that match to the character Funa
-C: Display the front and back n rows that match to the character Funa