Thursday, November 18, 2010

Using the grep command

This is how we can use the power of grep command to find 
the particular word in the file.

Syntax is:
grep [options] PATTERN [FILE

Example:
If I wanted to find the word "Name" in the file info.txt 
we can form the grep command as below
grep Name ./info.txt

If you want to know the line number just add the option -n. 
The above command is modified as below.
grep -n Name ./info.txt

No comments:

Post a Comment