← 返回列表

Linux shell egrep 命令

Linux shell egrep 命令用于在文件内查找指定的字符串 egrep 执行效果与 grep-E 相似,使用的语法及参数可参照 grep 指令,与 grep 的不同点在于解读字符串的方法。 egrep 是用 extended regular expression 语法来解读的,而 grep则用 basic regular expression 语法解读 extended regular expression 比 basic regular expression 的表达更规范。 egrep 命令语法格式 egrep [范本模式] [文件或目录] 选项 [范本模式] 查找的字符串规则 [文件或目录] 查找的目标文件或目录 范例 显示文件中符合条件的字符。 例如,查找当前目录下所有文件中包含字符串 Sh 的文件 root@localhost ~]# egrep Sh * grep: abc: Is a directory anaconda-ks.cfg:timezone Asia/Shanghai --isUtc --nontp man-help.txt: Show all pages with any part of either their names or their descriptions man-help.txt: Show all pages with any part of either their names or their descriptions grep: shell: Is a directory 返回上一级

Linux shell egrep 命令用于在文件内查找指定的字符串

egrep 执行效果与 grep-E 相似,使用的语法及参数可参照 grep 指令,与 grep 的不同点在于解读字符串的方法。

egrep 是用 extended regular expression 语法来解读的,而 grep则用 basic regular expression 语法解读

extended regular expression 比 basic regular expression 的表达更规范。

egrep 命令语法格式

egrep [范本模式] [文件或目录]

选项

[范本模式] 查找的字符串规则 [文件或目录] 查找的目标文件或目录

范例

显示文件中符合条件的字符。

例如,查找当前目录下所有文件中包含字符串 Sh 的文件

root@localhost ~]# egrep Sh *
grep: abc: Is a directory
anaconda-ks.cfg:timezone Asia/Shanghai --isUtc --nontp
man-help.txt:         Show all pages with any part of  either  their  names  or  their  descriptions
man-help.txt:         Show  all  pages  with  any  part  of either their names or their descriptions
grep: shell: Is a directory

返回上一级

打开资源 ↗

交流与评论