Linux egrep命令怎么使用
更新:HHH   时间:2023-1-7


这篇文章主要介绍“Linux egrep命令怎么使用”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Linux egrep命令怎么使用”文章能帮助大家解决问题。

egrep

在文件内查找指定的字符串

补充说明

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

关于“Linux egrep命令怎么使用”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注天达云行业资讯频道,小编每天都会为大家更新不同的知识点。

返回开发技术教程...