Unix Blog

Thursday, January 27, 2011

grep search

To recursively search for a string in Linux
grep -ir searchstring *

To match exact search string
grep -w searchstring *

Ex:
line1: 192.168.80.14
line2: 192.168.80.141

grep 192.168.80.14 * will return both lines
grep -w 192.168.80.14 * will return only first line

To limit no. of grep results
grep searchstring * -m 1

Ex:
line1: 192.168.80.14
line2: 192.168.80.141

grep 192.168.80.14 * will return both lines
grep 192.168.80.14 * -m1 will return only one line

posted by Jayanthi Krishnamurthy @ 10:23 AM   0 Comments

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

Newer›  ‹Older

About Me

Name: Jayanthi Krishnamurthy

View my complete profile

Posts

  • grep search

Older Posts Newer Posts

Archives

Subscribe to
Posts [Atom]