Unix FGREP Loop

Rok2005
Rok2005 used Ask the Experts™
on
I have a list of specific IPS.  I'm trying fgrep lines containing those ips out a huge file.

The problem that i'm running into is that if i fgrep ips in the following format:

10.130.125.10 or 10.130.125.20

I will fgrep un-desired ips like 10.130.125.105... when i really want 10.130.125.10

QUESTION:

How can i set my code to fgrep specific ips even if some of the ip address exist in other ips?

cat DVR |
        while read x
                do
                        fgrep $x all1 >> foundDVR.out
 
done

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007

Commented:
see -f you can use the -w option
Top Expert 2007

Commented:
grep -w -f DVR all1 >foundDVR.out
Commented:
This solution worked for me.
fgrep \|$x\| all1 >> foundDVR.out



I tried the
grep -w -f DVR all1 > foundDVR.out

It just kept running and never return an output.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial