Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux rgrep command

Linux rgrep command

Linux Command Reference Linux Command Reference

The Linux rgrep command is used to recursively search for strings that match a pattern in files.

The rgrep command works similarly to grep; it searches for files whose contents contain a specified pattern. If a file's contents match the specified pattern, rgrep displays the line containing the pattern by default.

Syntax



rgrep [-?BcDFhHilnNrv][-R<范本样式>][-W<列长度>][-x<扩展名>][--help][--version][范本样式][文件或目录...]

Parameter descriptions:

Example

To find files in the current directory whose sentences contain the string "Hello", use the following command:



rgrep Hello * 

The search results are as follows:



$ rgrep Hello *             #在当前目录下查找句子中包含“Hello”字符串的文件  

testfile_1:Hello 95         #testfile_1中包含“Hello”字符串的句子  

testfile_2:Hello 2005       #testfile_2中包含“Hello”字符串的句子 

Linux Command Reference Linux Command Reference