Link to home
Start Free TrialLog in
Avatar of NYGiantsFan
NYGiantsFanFlag for United States of America

asked on

how to grep these two IP address

Hi,

I have two IP addresses

2/.2/.2./2

or

1/.1/.1/.1

I want to grep for both

I tried

grep -E -o "2/.2./2./2|1/.1/.1/1"  *
grep -E "2/.2./2./2|1/.1/.1/1"  *

Without success (the above commands are not pulling the correct IP)

Any ideas? Thanks.
Avatar of sentner
sentner
Flag of United States of America image

Why do you have forward slashes in there?  Replace those with backslashes (\) instead and you should be ok (presuming that the source file itself doesn't have slashes in there for some reason).
Avatar of Dan Craciun
Is grep different? I thought the escape character is \

1\.1\.1\.1
grep -iP '2\.2.\2\.2|1\.1\.1\.1'  *

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of simon3270
simon3270
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NYGiantsFan

ASKER

It worked without the -w
It works now, but it may fail in the future with different IP addresses and different data to be searched!

Thanks for the points!