PHP.ph

09 Nov, 2008

Grep

Posted by: aqua In: Linux

grep command is used to locate a pattern in a file. By default it prints the line that contains the pattern.

Syntax
grep [option] pattern [file]

grep must have a pattern.

Option for grep

-c, --count
prints a count of matching lines for each input file instead of the normal output.

-E, --extended - regexp
interprets the attern as extended regula expression

-e pattern, --regexp=pattern
uses pattern

-F, --fixed-strings
interprets the pattern as a list of fixed strings

-f file, --file=file
obtains the search pattern from file.

--help
brief help

-r, --recursive
reads all files under directory

Tags:

No Responses to "Grep"

Comment Form

PHP.ph is Digg proof thanks to caching by WP Super Cache!