Search:  
Gentoo Wiki

Gentoo:/bin/grep

This file is part of the Gentoo Structure index.
Parent Directory Related Links

Contents

About

grep searches for lines matching patterns.

Links


Grep's usage

Searching for word(s) in files within a given directory structure:

grep -R <word> <directory>

Word: Can range from a single character to a string of numbers, words, and alphanumeric expressions.

Directory: Any directory can be specified. (Note: you must have proper permissions in the directory in which you search)


Searching for multiple words within a file simultaneously from file or a pipe:

grep -E 'word1|word2' <file>

The above example shows how to invoke grep in the case that it's used to search within a particular file while outputting two words and display them both.

cat file |grep -E 'word1|word2'

The example above shows how to invoke grep in the case that it's used to search or read from a pipe while outputting two words and display them both.

Retrieved from "http://www.gentoo-wiki.info/Gentoo:/bin/grep"

Last modified: Wed, 18 Jun 2008 11:53:00 +0000 Hits: 676