FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 01-18-2008, 07:20 PM
ann kok
 
Default use grep or other command to get exactly pattern

Hi all

how can use grep or use other command to get exactly
pattern eg: 10.0.0.7 only?

eg: grep 10.0.0.7 file. I want to get 10.0.0.7 only
not

10.0.0.71
10.0.0.72
10.0.0.7

thank you


__________________________________________________ __________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 01-18-2008, 07:30 PM
Konstantin Svist
 
Default use grep or other command to get exactly pattern

ann kok wrote:

how can use grep or use other command to get exactly
pattern eg: 10.0.0.7 only?

eg: grep 10.0.0.7 file. I want to get 10.0.0.7 only
not


10.0.0.71
10.0.0.72
10.0.0.7




Use egrep instead - it allows you to use regular expressions.
Then write a regexp for your case. For instance, if you have end-of-line
right after the IP address, you can use '10.0.0.7$'




--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 01-18-2008, 07:32 PM
"John BORIS"
 
Default use grep or other command to get exactly pattern

You can do this
grep 10.0.0.7. filename

The last period may work as a space. Or do this
grep "10.0.0.7 " filename

That might work as well

John J. Boris, Sr.
JEN-A-SyS Administrator
Archdiocese of Philadelphia

"Remember! That light at the end of the tunnel
Just might be the headlight of an oncoming train!"

>>> ann kok <annkok2001@yahoo.com> 1/18/2008 3:20 PM >>>
Hi all

how can use grep or use other command to get exactly
pattern eg: 10.0.0.7 only?

eg: grep 10.0.0.7 file. I want to get 10.0.0.7 only
not

10.0.0.71
10.0.0.72
10.0.0.7

thank you



__________________________________________________ __________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 01-18-2008, 07:35 PM
Steve Searle
 
Default use grep or other command to get exactly pattern

Around 08:20pm on Friday, January 18, 2008 (UK time), ann kok scrawled:

> how can use grep or use other command to get exactly
> pattern eg: 10.0.0.7 only?
>
> eg: grep 10.0.0.7 file. I want to get 10.0.0.7 only
> not

grep 10.0.0.7$ file

Assuming that there is nothing else on the line after the IP address.

Steve

--

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting a bad thing?

20:34:32 up 111 days, 7:31, 1 user, load average: 0.09, 0.08, 0.01
--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 01-18-2008, 07:35 PM
"Robert P. J. Day"
 
Default use grep or other command to get exactly pattern

On Fri, 18 Jan 2008, John BORIS wrote:

> You can do this
> grep 10.0.0.7. filename
>
> The last period may work as a space. Or do this
> grep "10.0.0.7 " filename
>
> That might work as well

i would use the "-w" option to force the string to be a separate word.

rday
--
================================================== ======================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

Home page: http://crashcourse.ca
Fedora Cookbook: http://crashcourse.ca/wiki/index.php/Fedora_Cookbook
================================================== ======================

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 01-18-2008, 07:37 PM
Norman Gaywood
 
Default use grep or other command to get exactly pattern

ann kok wrote:
> how can use grep or use other command to get exactly
> pattern eg: 10.0.0.7 only?
>
> eg: grep 10.0.0.7 file. I want to get 10.0.0.7 only
> not
> 10.0.0.71
> 10.0.0.72
> 10.0.0.7

grep '^10.0.0.7$' file

The ^ means the start of the line, . means match a "." character. If
you just used . it means to match any character. $ means the
end of the line.
--
Norman Gaywood, Systems Administrator
University of New England, Armidale, NSW 2351, Australia

ngaywood@une.edu.au Phone: +61 (0)2 6773 3337
http://mcs.une.edu.au/~norm Fax: +61 (0)2 6773 3312

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 01-18-2008, 08:12 PM
"Mark C. Allman"
 
Default use grep or other command to get exactly pattern

On Fri, 2008-01-18 at 20:35 +0000, Steve Searle wrote:
> Around 08:20pm on Friday, January 18, 2008 (UK time), ann kok scrawled:
>
> > how can use grep or use other command to get exactly
> > pattern eg: 10.0.0.7 only?
> >
> > eg: grep 10.0.0.7 file. I want to get 10.0.0.7 only
> > not
>
> grep 10.0.0.7$ file
>
> Assuming that there is nothing else on the line after the IP address.
>
> Steve
>
> --
> fedora-list mailing list
> fedora-list@redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

To be nice and general:
grep '10.0.0.7[^0-9]' file
or grep '10.0.0.7[^:digit:]' file

-- Mark C. Allman, PMP
-- Allman Professional Consulting, Inc.
-- www.allmanpc.com, 617-947-4263

BusinessMsg -- the secure, managed, J2EE/AJAX Enterprise IM/IC solution




--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 01-18-2008, 08:42 PM
John Summerfield
 
Default use grep or other command to get exactly pattern

ann kok wrote:

Hi all

how can use grep or use other command to get exactly
pattern eg: 10.0.0.7 only?

eg: grep 10.0.0.7 file. I want to get 10.0.0.7 only
not


10.0.0.71
10.0.0.72
10.0.0.7


man grep
man regex

--

Cheers
John

-- spambait
1aaaaaaa@coco.merseine.nu Z1aaaaaaa@coco.merseine.nu
-- Advice
http://webfoot.com/advice/email.top.php
http://www.catb.org/~esr/faqs/smart-questions.html
http://support.microsoft.com/kb/555375

You cannot reply off-list:-)

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 01-19-2008, 01:06 AM
Brian Chadwick
 
Default use grep or other command to get exactly pattern

Konstantin Svist wrote:

ann kok wrote:

how can use grep or use other command to get exactly
pattern eg: 10.0.0.7 only?

eg: grep 10.0.0.7 file. I want to get 10.0.0.7 only
not
10.0.0.71

10.0.0.72
10.0.0.7




Use egrep instead - it allows you to use regular expressions.
Then write a regexp for your case. For instance, if you have
end-of-line right after the IP address, you can use '10.0.0.7$'





grep "10.0.0.7" file

the inverted commas are required

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 01-19-2008, 01:45 AM
"Aldo Foot"
 
Default use grep or other command to get exactly pattern

On Jan 18, 2008 12:20 PM, ann kok <annkok2001@yahoo.com> wrote:

Hi all

how can use grep or use other command to get exactly
pattern eg: 10.0.0.7 only?

eg: grep 10.0.0.7 file. I want to get
10.0.0.7 only
not

10.0.0.71
10.0.0.72

10.0.0.7

thank you


* * *_________________________________________________ ___________________________________
Never miss a thing. *Make Yahoo your home page.

http://www.yahoo.com/r/hs

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe:
https://www.redhat.com/mailman/listinfo/fedora-list
If there is something else in the line in addition to 10.0.0.7
example: 10.0.0.7
word1 word2 number1...
then use
** > grep -w 10.0.0.7 myfile | awk '{print $1}'

*if 10.0.0.7 is the second field then use '{print $2}' and so on.

~af


--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 

Thread Tools




All times are GMT. The time now is 12:15 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org