1834021 Members
2292 Online
110063 Solutions
New Discussion

Precision "grep"

 
SOLVED
Go to solution
D. Jackson_1
Honored Contributor

Precision "grep"

I am trying to search an entire system for a specific ip address string (182.101.*). I DO NOT want the grep to pick up anything prior to the 182. . I am using this for my current search /> find ./ -type f -print |xargs grep "182.101." ...
Is there another way to get exactly what I need????
Thanks for the assistance...
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor
Solution

Re: Precision "grep"

Dustin:

Anchor the string, as:

...grep "^182"

...JRF...
Stefan Farrelly
Honored Contributor

Re: Precision "grep"


I think your way of doing it is rather inefficient. It must build up a complete list from the find command before piping into xargs then into grep. I think its much faster and efficient to let find do the work;

find ./ -type f -exec grep "182.101." {} \;
Im from Palmerston North, New Zealand, but somehow ended up in London...
Rainer_1
Honored Contributor

Re: Precision "grep"

use grep "^182\.101\."
this pattern lists only lines the begins with 182
D. Jackson_1
Honored Contributor

Re: Precision "grep"

Okay this worked both ways....
Thanks guys.

DJ
D. Jackson_1
Honored Contributor

Re: Precision "grep"

Okay this worked both ways....
Thanks guys.

DJ