Tuesday, 14 January 2014

What is the use of ‘grep’ command?

‘grep’ is a pattern search command. It searches for the pattern, specified in the command line with appropriate option, in a file.
Syntax:
grep string file - Searches input file(s) for specified string and prints the line with matches.
grep -c string file - Searches and prints only the number of matches to the screen .
grep -i string file - Searches without regard to letter case.
grep -n string file - Prints to the screen preceded by the line number.
grep -v string file - All lines that do not match are printed.
grep -x string file - Only exact matches are printed.





No comments:

Post a Comment