Jo wrote:
> 
> Well, I'm trying to find out my dynamically assigned IP address. I got
> this far:
> 
> ifconfig > ifc
> grep --context=1 eth1 ifc > ifc1
> grep "inet addr:" ifc1 > ifc2
> 
> Now I have to get the IP address from that line I isolated into a
> variable.
>
> Axalon wrote:
> >
> > On Fri, 9 Jul 1999, Yants wrote:
> >
> > > how do i write shell scripts..?
> > > can someone please show me an example...
> > >
> >
> > -=-=- useless bash script v1.0
> > #!/bin/bash
> > sleep 10
> > -=-=-

How 'bout this one-liner:

IFADDR=`/sbin/ifconfig eth1 | grep "inet addr:" | cut -f2 -d: | cut -f1
-d" "`

IFADDR gets the output of the command pipeline inside the `s.  Get the
output of /sbin/ifconfig for the specific interface, grab just the
address line, grab from the colon to the next colon, then trim off the
end of the IP address.

Anyone got anything shorter?? 
-- 
Steve Philp
Network Administrator
Advance Packaging Corporation
[EMAIL PROTECTED]

Reply via email to