Regarding the use of grep commands
Function description: Find the qualified string in the file.
The grep command is very useful in the case of a pattern-based search on the contents of one or more files. The pattern can be a single character, multiple characters, a single word, or a sentence. When the command matches the pattern specified when the command is executed, grep will output a line containing the pattern, but does not modify the contents of the original file.
First talk about the common format of the grep command: grep [Options] Find content source files
Next is to bring the options to operate
The following are some commonly used options
Options | Features |
---|---|
-n | Show matching line and line number |
-i | Ignore letter case |
-c | Shows how many lines are matched instead of displaying the matched content. Note that if the -cv option is used at the same time, it will show how many lines are not matched. |
-V | Display version information |
–color | Highlight the matched content in color. |
-The | Only display the string matched by the pattern. |
-w | The matched text can only be a word, not a certain part of the word. For example, if there is liker in the text, and I searched for just like, you can use the -w option to avoid matching liker |
This is what I found in a book, it is more practical
In addition, for the content to be matched, you can enter the following two parts:
1. Enter the string to be matched directly
2. Use basic regular expressions
That's all about grep this time.