use grep or other command to get exactly pattern

Aldo Foot lunixer at gmail.com
Sat Jan 19 02:45:35 UTC 2008


On Jan 18, 2008 12:20 PM, ann kok <annkok2001 at 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 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20080118/9860910d/attachment-0001.htm>


More information about the fedora-list mailing list