I use bash shell Thank you all --- "Schott, Erik J Mr ANOSC/FCBS" <erik.schott-FCBS@xxxxxxxxxxxxxxx> wrote: > Which shell are you using? > > ksh/bash/zsh: ipaddr=`grep truc /etc/hosts | cut > -f1 -d" "` (note the > graves (back ticks)) > > csh/tcsh: set ipaddr `grep truc /etc/hosts | cut > -f1 -d" "` (note the > graves (back ticks)) > > -----Original Message----- > From: redhat-list-bounces@xxxxxxxxxx > [mailto:redhat-list-bounces@xxxxxxxxxx]On Behalf Of > truc nguyen > Sent: Monday, January 03, 2005 5:12 PM > To: General Red Hat Linux discussion list > Subject: Re: Script > > > If I want to put it in variable "ipaddr" > grep truc /etc/hosts | cut -f1 -d" " > $ipaddr > > Is that correct ? > > Thanks, > > --- "Benjamin J. Weiss" <benjamin@xxxxxxxxxxx> > wrote: > > > 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@xxxxxxxxxx?subject=unsubscribe > > > https://www.redhat.com/mailman/listinfo/redhat-list > > > > > > > __________________________________ > Do you Yahoo!? > Take Yahoo! Mail with you! Get it on your mobile > phone. > http://mobile.yahoo.com/maildemo > > -- > redhat-list mailing list > unsubscribe > mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe > https://www.redhat.com/mailman/listinfo/redhat-list > > -- > redhat-list mailing list > unsubscribe > mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe > https://www.redhat.com/mailman/listinfo/redhat-list > __________________________________ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo -- redhat-list mailing list unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe https://www.redhat.com/mailman/listinfo/redhat-list