Linux egrep command
Complete Linux Command Reference
The Linux egrep command is used to search for specified strings within files.
The execution effect of egrep is similar to "grep -E". The syntax and parameters used can refer to the grep command. The difference from grep lies in the method of interpreting strings.
egrep interprets using the extended regular expression syntax, while grep interprets using the basic regular expression syntax. Extended regular expressions are more standardized in expression than basic regular expressions.
Syntax
egrep [范本模式] [文件或目录]
Parameter description:
- [Pattern mode]: The string rule to search for.
- [File or directory]: The target file or directory to search.
Examples
Display characters in a file that meet the conditions. For example, to find files containing the string "Linux" among all files in the current directory, use the following command:
egrep Linux *
The result is as follows:
$ egrep Linux * #查找当前目录下包含字符串“Linux”的文件 testfile:hello Linux! #以下五行为testfile 中包含Linux字符的行 testfile:Linux is a free Unix-type operating system. testfile:This is a Linux testfile! testfile:Linux testfile:Linux testfile1:helLinux! #以下两行为testfile1中含Linux字符的行 testfile1:This a Linux testfile! #以下两行为testfile_2 中包含Linux字符的行 testfile_2:Linux is a free unix-type opterating system. testfile_2:Linux test xx00:hello Linux! #xx00包含Linux字符的行 xx01:Linux is a free Unix-type operating system. #以下三行为xx01包含Linux字符的行 xx01:This is a Linux testfile! xx01:LinuxOther extensions