You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

egrep
===
在文件内查找指定的字符串
## 说明
**egrep命令** 用于在文件内查找指定的字符串。egrep执行效果与`grep -E`相似使用的语法及参数可参照grep指令与grep的不同点在于解读字符串的方法。egrep是用extended regular expression语法来解读的而grep则用basic regular expression 语法解读extended regular expression比basic regular expression的表达更规范
## 选项
```
egrep(选项)(查找模式)(文件名1文件名2……)
```
## 实例
显示文件中符合条件的字符。例如,查找当前目录下所有文件中包含字符串"Linux"的文件,可以使用如下命令:
```
egrep Linux *
```
结果如下所示:
```
#以下五行为 testfile 中包含Linux字符的行
testfile:hello Linux!
testfile:Linux is a free Unix-type operating system.
testfile:This is a Linux testfile!
testfile:Linux
testfile:Linux
#以下两行为testfile1中含Linux字符的行
testfile1:helLinux!
testfile1:This a Linux testfile!
#以下两行为 testfile_2 中包含Linux字符的行
testfile_2:Linux is a free unix-type opterating system
testfile_2:Linux test
```