Egrep

来自 ChinaUnix Wiki

Linux命令:grep

功能说明:在文件内查找指定的字符串。

egrep执行效果如grep -E,使用的语法及参数可参照grep指令,与grep不同点在于解读字符串的方法,egrep是用extended regular expression语法来解读,而grep则用basic regular expression语法,extended regular expression比basic regular expression有更完整的表达规范。


英文版本,欢迎翻译:

ABOUT EGREP

Search a file for a pattern using full regular expressions.

SYNTAX

egrep [-b] [-c] [-h] [-i] [-l] [-n] [-s] [-v] [-x] [ -e pattern_list ] [-f file ] [ strings ] [ file]

-b Precede each line by the block number on which it was found. This can be useful in locating block numbers by context (first block is 0). -c Print only a count of the lines that contain the pattern. -h Suppress printing of filenames when searching multiple files. -i Ignore upper/lower case distinction during comparisons. -l Print the names of files with matching lines once, separated by NEWLINEs. Does not repeat the names of files when the pattern is found more than once. -n Precede each line by its line number in the file (first line is 1). -s Work silently, that is, display nothing except error messages. This is useful for checking the error status. -v Print all lines except those that contain the pattern. -x Consider only input lines that use all characters in the line to match an entire fixed string or regular expression to be matching lines. -e pattern_list Search for a pattern_list (full regular expression that begins with a -). -f file Take the list of full regular expressions from file. strings Specify a pattern to be used during the search for input. file A path name of a file to be searched for the patterns. If no file operands are specified, the standard input will be used.

EXAMPLES

egrep "support|help|windows" myfile.txt - Would search for patterns of support help and windows in the file myfile.txt.

个主工具