English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Linuxのegrepコマンドはファイル内で指定された文字列を検索するために使用されます。
egrepの実行結果は"grep-E"似ており、使用される構文およびパラメータは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-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-operating system. testfile_2:Linux test xx00:hello Linux! #xx00含Linux文字の行 xx01:Linux is a free Unix-operating system. #以下三行はxx01Linux文字を含む行 xx01:This is a Linux testfile! xx01:Linux