egrep
Linuxのegrepコマンド 構(gòu)文
機(jī)能: egrep コマンドは、ファイル內(nèi)の指定された文字列を検索するために使用されます。
構(gòu)文: egrep [テンプレートモード] [ファイルまたはディレクトリ]
Linuxのegrepコマンド 例
ファイル內(nèi)の修飾された文字を表示します。たとえば、現(xiàn)在のディレクトリ內(nèi)のすべてのファイルで文字列「Linux」を含むファイルを検索するには、次のコマンドを使用できます:
egrep Linux *
結(jié)果は次のとおりです:
$ egrep Linux * #查找當(dāng)前目錄下包含字符串“Linux”的文件 testfile:hello Linux! #以下五行為testfile 中包含Linux字符的行 testfile:Linux is a free Unix-type operating system. testfile:This is a Linux testfile! testfile:Linux testfile:Linux testfile1:helLinux! #以下兩行為testfile1中含Linux字符的行 testfile1:This a Linux testfile! #以下兩行為testfile_2 中包含Linux字符的行 testfile_2:Linux is a free unix-type opterating system. testfile_2:Linux test xx00:hello Linux! #xx00包含Linux字符的行 xx01:Linux is a free Unix-type operating system. #以下三行為xx01包含Linux字符的行 xx01:This is a Linux testfile! xx01:Linux