LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-13-2008, 10:28 AM   #1
Panagiotis_IOA
Member
 
Registered: Jan 2006
Location: Hellas, Europe
Distribution: Slackware 12
Posts: 238

Rep: Reputation: 32
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!
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-13-2008, 10:38 AM   #2
Panagiotis_IOA
Member
 
Registered: Jan 2006
Location: Hellas, Europe
Distribution: Slackware 12
Posts: 238

Original Poster
Rep: Reputation: 32
SOLVED.

I should have read better the man page. The option -w seems to do the trick.
 
5 members found this post helpful.
Old 01-20-2014, 04:34 AM   #3
shaileshmshinde
LQ Newbie
 
Registered: Jan 2014
Posts: 1

Rep: Reputation: Disabled
Lightbulb

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


Reply

Tags
cat, string


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
grep exact letters packets Linux - Newbie 1 11-30-2007 08:39 PM
grep/sed/awk - find match, then match on next line gctaylor1 Programming 3 07-11-2007 08:55 AM
how to find an exact substring match? ldp Programming 7 02-22-2005 06:28 AM
grep [exact phrase] chrisfirestar Linux - General 2 02-09-2004 04:30 AM
how to grep only one string pr match gummimann Linux - General 3 11-06-2003 09:40 AM


All times are GMT -5. The time now is 11:19 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration