LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   grep question - match exact string (https://www.linuxquestions.org/questions/linux-general-1/grep-question-match-exact-string-620846/)

Panagiotis_IOA 02-13-2008 11:28 AM

grep question - match exact string
 
Hi all,

I have a file with a list of IP addresses. For instance:

192.168.10.5
192.168.10.15
192.168.10.16
192.168.10.155
....

I want to run grep over it and get as a result only the second one, 192.168.10.15:

Code:

grep 192.168.123.15 ~/ip_list
The result is that I get both 192.168.10.15 and 192.168.10.155

How can I match only the .15 IP? I tried a few things while googling but no luck.

Thanks a lot in advance!

Panagiotis_IOA 02-13-2008 11:38 AM

SOLVED.

I should have read better the man page. The option -w seems to do the trick.

shaileshmshinde 01-20-2014 05:34 AM

"grep -Fx 192.168.123.15 ip_list" or "cat as |grep -Fx 192.168.10.15"


All times are GMT -5. The time now is 05:24 AM.