From Juneday education
Jump to: navigation, search


grep - print lines matching a pattern.

On this page we only give you a short introduction with a few examples. We encourage you to read the manual (man grep).

grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. Its name comes from the ed command g/re/p (globally search a regular expression and print), which has the same effect: doing a global search with the regular expression and printing all matching lines.

(Source: [1] - Creative Commons Attribution-ShareAlike License)

Example output

Search for lines containing a regular expression

$ grep just one-file.txt
This is just some text

Compare this to a printout of the entire content of the file:

$ cat one-file.txt
Hi there

This is just some text 
/John Doe