grep

grep is a tool to extract text lines from files (or command outputs using pipes). You’ll use it without end once you’ll know how to do!

$ grep pattern from_file

$ cat from_file | grep pattern

$ some_command_text_output | grep pattern

The pattern may be of various formats, of which plain text or regexp.

Some options may change the behaviour of grep:

$ grep -i pattern from_file

will extract the lines matching pattern without matching the case

$ grep -v pattern from_file

will extract the lines not matching the pattern

$ grep -r pattern from_files

recursively looks in a directory and all his subdirectories

Some tools with other similar names are just quick access to some options of grep, like egrep or rgrep(recursively looks in a directory and all his subdirectories).

This article was first written in July 2003 for
the BeezNest technical website (http://glasnost.beeznest.org/articles/47)
Categories: English, OSS Solutions Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: