Home > Article > Operation and Maintenance > What is grep in linux
In Linux, grep is a command of the system. This command is the abbreviation of "global regular expression print" global regular expression output. It is used to find qualified strings in files. The syntax is "grep[ -abcEFGhHilLnqrsvVwxy]".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
The grep command is the abbreviation of global regular expression print (global regular expression output). It is one of the most powerful commands in the Linux system. It searches one or more files for lines matching the given content and outputs the matching content.
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 the file name is - -, the grep command reads data from the standard input device.
grep syntax format:
grep [参数]
Common parameters:
-i: ignore case
-c: Only output the number of matching lines
-l: Only list matching file names, do not list specific matching lines
-n: List all matching lines and display the line number
-h: Do not display the file name when querying multiple files
-v: Display all lines that do not contain matching text
-w: Match whole words
-x: Match whole lines
-r: Recursively search the
test directory, the file contents are all the same:
Example 1. Search for the string
grep test test01.txt
grep -i test test01.txt#Ignore case
grep -n test test01.txt#-n displays line numbers
##grep -v 003 test01.txt#-v displays unmatched lines, Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What is grep in linux. For more information, please follow other related articles on the PHP Chinese website!