Text search command
Article Directory
learning target
- To know the commands used in text search
Use 1. grep command
command | Explanation |
---|---|
grep | Text search |
grep command renderings:
Use 2. grep command options
Command Options | Explanation |
---|---|
-i | Ignore case |
-n | Display line numbers match |
-v | Display does not contain matching text of all lines |
-i command options renderings:
-n command option renderings:
-v command options renderings:
3. grep command in conjunction with regular expressions
Regular Expressions | Explanation |
---|---|
^ | Beginning with the specified string |
$ | End with the specified string |
. | A non-matching character newline |
Regular expression '^' renderings:
Regular expression '$' renderings:
'.' Renderings regular expression:
4. Extension
- grep command can also search for text content in the pipeline, such as: LS / | grep 'lib'
- Using grep can also search the contents of quotation marks omitted when the command, such as: LS / | grep lib , grep the Hello 1.txt
5. Summary
- grep command is completed text search operation
- Format text search: grep text search options content