What is the syntax of Linux grep command

WBOY
Release: 2023-05-14 22:43:11
forward
1480 people have browsed it

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 the file name is - -, the grep command reads data from the standard input device.

Syntax:

grep
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, the content after the row is also displayed.

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

-B or --before-context= : In addition to displaying the line that matches the style, the content before that line is also displayed.

-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, and display this line Before and after content.

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

-e

-E or --extended-regexp : Use extended regular expression style.

-f or --file= : Specify a rule file whose content contains one or more rule styles, allowing grep to find file contents and formats that meet the rule conditions. One rule style for each row.

-F or --fixed-regexp : Treat styles as a list of fixed strings.

-G or --basic-regexp : Use the style as a normal representation.

-h or --no-filename : Do not indicate the file name to which the line belongs before displaying the line that matches the style.

-H or --with-filename : Before displaying the line that matches the style, indicates the file name to which the line belongs.

-i or --ignore-case : Ignore differences in character case.

-l or --file-with-matches : List the file names whose file contents match the specified pattern.

-L or --files-without-match : List the file names whose file contents do not match the specified style.

-n or --line-number: Before displaying the line that matches the style, indicate the column number of the line.

-o or --only-matching: Only display the matching PATTERN part.

-q or --quiet or --silent : Do not display any information.

-r or --recursive: The effect of this parameter is the same as specifying the "-d recurse" parameter.

-s or --no-messages : Do not display error messages.

-v or --invert-match : Display all lines that do not contain matching text.

-V or --version : Display version information.

-w or --word-regexp: Only display columns that match the full word.

-x --line-regexp : Only display columns that match all columns.

-y: The effect of this parameter is the same as specifying the "-i" parameter.

The above is the detailed content of What is the syntax of Linux grep command. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!