egrep
egrep功能说明:在文件内查找指定的字符串。egrep执行效果如grep -E,使用的语法及参数可参照grep指令,与grep不同点在于解读字符串的方法,egrep是用extended regular expression语法来解读,而grep则用basic regular expression语法,extended regular expression比basic regular expression有更完整的表达规范。
egrep
egrep [options] [regexp] [files]
Search one or more files for lines that match an extended regular expression regexp. egrep doesn't support the regular expressions (, ), n, <, >, {, or }, but it does support the other expressions, as well as the extended set +, ?, |, and ( ). Remember to enclose these characters in quotes. Regular expressions are described in Chapter 7. Exit status is 0 if any lines match, 1 if none match, and 2 for errors.
See grep for the list of available options. Also see fgrep.
Examples
Search for occurrences of Victor or Victoria in file:
egrep 'Victor(ia)*' file egrep '(Victor|Victoria)' file
Find and print strings such as old.doc1 or new.doc2 in files, and include their line numbers:
egrep -n '(old|new).doc?' files