[LBo] looking for command
Ray
ray at stilltech.net
Thu Mar 22 05:14:19 CET 2007
On Sunday 18 March 2007 1:22 pm, Alan Lake wrote:
> Don't know if this interests anybody, but I put it into a Ruby program
> that looks like this:
> ---------------------
> #!/usr/bin/env ruby
>
> ip = `ifconfig eth0 | grep "inet addr" | sed -e "s/inet addr://" | sed
> -e "s/ Bcast.*//"`.strip
> puts "My IP is #{ip}"
> ----------------------------
>
> Chris F.A. Johnson wrote:
> > On Sun, 18 Mar 2007, Jason Armstrong wrote:
> >>> I could do this for ipv4 of my wireless card:
> >>>
> >>> ifconfig wlan0 | grep "inet addr" | sed -e "s/inet addr://" | \
> >>> sed -e "s/ Bcast.*//"
> >>>
> >>> Putting it into a shell script should be simple enough
> >>
> >> That's some mad pipage. If you're using sed there's no reason to use
> >> grep at all:
> >>
> >> ifconfig eth0 | sed -n 's/^.*addr:\(.*\) B.*$/\1/p'
> >
> > There's no need to use sed, either. See my post in this thread.
Hello all,
I just realized that I forgot to thank everyone for your help.
My thanks to all who responded to my question.
Ray
More information about the QnA
mailing list