The execution result of egrep is similar to that of "grep-E". The syntax and parameters used can be referred to the grep command. The difference between egrep and grep lies in the method of interpreting strings.
Egrep is interpreted using extended regular expression syntax, while grep is interpreted using basic regular expression syntax. extended regular expression is more standard than basic regular expression.
Syntax
Egrep [template mode] [file or directory]
Parameter description:
- [Template mode]: string rule to be searched.
- [File or directory]: find the target file or directory.
Instance
Displays the matching characters in the file. For example, to find all files in the current directory that contain the string "Linux", run the following command:
Egrep Linux *
The result is as follows:
$ Egrep Linux * # search for files containing the string "Linux" in the current directory
Testfile: hello Linux! # The following five lines contain Linux characters in testfile.
Testfile: Linux is a free Unix-type operating system.
Testfile: This is a Linux testfile!
Testfile: Linux
Testfile: Linux
Testfile1: helLinux! # The following two lines in testfile1 contain Linux characters:
Testfile1: This a Linux testfile!
# The following two rows in testfile_2 contain Linux characters:
Testfile_2: Linux is a free unix-type opterating system.
Testfile_2: Linux test
Xx00: hello Linux! # Xx00 lines containing Linux characters
Xx01: Linux is a free Unix-type operating system. # the following three actions xx01 contain Linux characters
Xx01: This is a Linux testfile!
Xx01: Linux