Re: using grep to find IP address...

From: Thorn (Raptor_at_Etruscan.Warrior)
Date: 05/31/05


Date: Tue, 31 May 2005 11:00:57 -0500

On 31 May 2005 08:30:41 -0700, balgach@gmail.com Cried: Read These Runes!:
> Hello all, i am interested in the last 255 bits of the local machines
> ip address (aka the last number after the period) so far ive been
> using the command, i know all the ip address start with 192.168
>
> ifconfig | grep '192.168' | awk '{print $2}'
>
> which is returning:
>
> inet addr:192.168.0.20
>
>
> now how do i get it just to return the '20' ??

There's got to be an easier way:

/sbin/ifconfig | grep inet | cut -d . -f 4 | cut -d " " -f 1

Thorn

-- 
"I am not sure what this is, but an `F' would only dignify it."
		-- English Professor


Relevant Pages

  • Re: using grep to find IP address...
    ... i am interested in the last 255 bits of the local machines ... > ip address (aka the last number after the period) so far ive been ... use Perl; ...
    (comp.unix.shell)
  • Re: using grep to find IP address...
    ... i am interested in the last 255 bits of the local machines ... > ip address (aka the last number after the period) so far ive been ... Depend on the rabbit's foot if you will, but remember, it didn't help the rabbit. ...
    (comp.unix.shell)
  • Re: using grep to find IP address...
    ... i am interested in the last 255 bits of the local machines ... > ip address (aka the last number after the period) so far ive been ... > Adam. ... Bill Seivert ...
    (comp.unix.shell)
  • Re: using grep to find IP address...
    ... Greg Beeker wrote: ... i am interested in the last 255 bits of the local machines ... >>ip address (aka the last number after the period) so far ive been ... Regards, ...
    (comp.unix.shell)