NYGiantsFan
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.
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.
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).
Is grep different? I thought the escape character is \
1\.1\.1\.1
1\.1\.1\.1
grep -iP '2\.2.\2\.2|1\.1\.1\.1' *
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
Thanks for the points!