What is the usage of grep in linux

WBOY
Release: 2021-12-27 17:34:56
Original
23499 people have browsed it

In Linux, the grep command is used to find qualified strings in files. The syntax is "grep option pattern file"; this command can find files containing the specified template style. If the file content matches the specified template style, the column containing the template style will be displayed.

What is the usage of grep in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What is the usage of grep in Linux

The Linux grep command is used to find strings that meet the conditions in the file.

The grep command is used to find files whose content contains the specified template style. If the content of a file is found to match the specified template style, the default grep command will display the column containing the template style. If no file name is specified, or if - is given, the grep command reads data from the standard input device.

Syntax

grep [-abcEFGhHilLnqrsvVwxy][-A<显示行数>][-B<显示列数>][-C<显示列数>][-d<进行动作>][-e<范本样式>][-f<范本文件>][--help][范本样式][文件或目录...]
Copy after login

Parameters:

  • -a or --text: Do not ignore binary data.

  • -A or --after-context= : In addition to displaying the column that conforms to the template style, and display this row What follows.

  • -b or --byte-offset: Before displaying the line that matches the style, indicate the number of the first character of the line.

  • -B or --before-context= : In addition to displaying the line that conforms to the style, and displaying the line before Content.

  • -c or --count : Count the number of columns that match the style.

  • -C or --context= or - : In addition to displaying the line that matches the style outside, and displays the content before and after the line.

  • ##-d or --directories= : This parameter must be used when specifying directories rather than files to be searched, otherwise grep The command will report the information and stop the action.

  • -e