Linux egrepコマンド

Linux 命令大全Linux コマンド大全

Linux egrepコマンドは、ファイル内で指定された文字列を検索するために使用します。

egrepの実行効果は"grep-E"と似ており、使用する構文やパラメータはgrepコマンドを参照できます。grepとの違いは、文字列を解釈する方法にあります。

egrepはextended regular expression構文で解釈し、grepはbasic regular expression構文で解釈します。extended regular expressionはbasic regular expressionよりも表現がより規範的です。

構文

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

パラメータの説明:

  • [パターン]:検索する文字列の規則。
  • [ファイルまたはディレクトリ]:検索の対象となるファイルまたはディレクトリ。

例

ファイル内の条件に一致する文字を表示します。例えば、現在のディレクトリ以下のすべてのファイルから文字列"Linux"を含むファイルを検索するには、次のコマンドを使用できます:

egrep Linux *

結果は次のようになります:

$ egrep Linux * #查找当前目录下包含字符串“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 

Linux 命令大全Linux コマンド大全

その他の拡張