grep: Search the Content of Files
grep | |
---|---|
Category | Command Line Program |
Part Of | GUN Core Utilities |
Classification | Tier 1 |
Official Documentation | grep |
1 Description
The purpose of grep is to search through text files and output lines of text that match a given pattern to STDOUT.
2 Examples
2.1 How To Recursively Search For A String
The example provided below will recursively search -r
all files
which match the given regular expression *
for the given string
html
.
When a match is found, 3 lines of context from the matching file
will be output -C 3
, the output lines will be numbered -n
and
the output will be highlighted in different colors --color=always
.
user-1@vm:~$ grep --color=always -n -r -i -C 3 -e html *
user-1@vm:~$
This document was last updated: