English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux rgrep command

Linux Command大全

The Linux rgrep command is used to recursively search for strings that match the specified criteria within files.

The functionality of the rgrep command is similar to that of the grep command, which can search for files containing specified template styles. If a file's content matches the specified template style, the rgrep command will display the column containing the template style by default.

Syntax

rgrep [-?BcDFhHilnNrv][-R<Template style>][-W<column length>][-x<extension>][--help][--version][Template style][File or directory...]

Parameter description:

  • -? Displays the description of the template style and examples.
  • -B Ignores binary data.
  • -c Calculates the number of columns that match the template style.
  • -D Error mode, only lists the directory list searched by the instruction, without reading the file content.
  • -F When encountering symbolic links, rgrep defaults to ignoring them and not processing them. Adding this parameter will make rgrep read the content of the original file pointed to by the link.
  • -h Specifically mark strings that match the template style.
  • -H Only list strings that match the template style, rather than displaying the entire column content.
  • -i Ignore the difference in character case.
  • -l List file names whose contents match the specified template style.
  • -n Before displaying the column that matches the template style, indicate the column number of that column.
  • -N Do not process recursively.
  • -R Recursive processing, processing all files and subdirectories in the specified directory.
  • -R<Template Style> The effect of this parameter is similar to that of specifying "-r parameters similar, but only focus on files with names that match the template style.
  • -v Reverse search.
  • -W<column length> Limit the number of characters that must be owned by the string that matches the template style in the column.
  • -x<extension> Only process files with the specified extension names.
  • --help Online help.
  • --version Display version information.

Online Examples

To find files in the current directory that contain the string 'Hello', you can use the following command:

rgrep Hello * 

The search results are as follows:

$ rgrep Hello *             #Find files in the current directory that contain the string 'Hello'  
testfile_1:Hello 95         #testfile_1Sentences containing the string 'Hello'  
testfile_2:Hello 2005       #testfile_2Sentences containing the string 'Hello' 

Linux Command大全