grep (unix program)
The grep program searches a file (or files) for lines that contain a particular pattern. The syntax is:
- grep pattern file(s)
The name grep
derives from the ed command g/re/p which means globally search for a regular expression and print all lines found
. A regular expression can be simple plain text (perhaps a word) or special characters used for pattern matching.
The simplest use of grep is to look for a pattern consisting of a single word.
grep - commonly used options
- -v Print all lines that do not match the specified pattern
- -n Print the line and its line number.
- -l Print only the file names.
- -c Print only the count of lines.
- -i Case insensitive.