[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: Script



Or you could use

grep truc /etc/hosts | cut -c1-15

-----Original Message-----
From: redhat-list-bounces redhat com
[mailto:redhat-list-bounces redhat com]On Behalf Of Benjamin J. Weiss
Sent: Monday, January 03, 2005 2:38 PM
To: General Red Hat Linux discussion list
Subject: Re: Script


truc nguyen wrote:

>Hi,
>
>In my hosts file, the last line is as follow
>197.2.23.134      truc TRUC
>
>I want to write a script to get the this IP address.
>What command in sed or awk to execute this ?
>
>Thank you so much
>
>  
>
I see that you've gotten a couple of answers already.  However, in the 
interests of "There's more than one way to do it", here's another approach:

 grep truc /etc/hosts | grep -o 
"[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}"

or

grep truc /etc/hosts | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"

or

grep truc /etc/hosts | cut -f1 -d" "

I'm sure that there are others. :)

Ben

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request redhat com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]