Re: using grep to find IP address...
From: Ed Morton (morton_at_lsupcaemnt.com)
Date: 05/31/05
- Next message: Ed Morton: "Re: using grep to find IP address..."
- Previous message: Ed Morton: "Re: Case statement"
- In reply to: Greg Beeker: "Re: using grep to find IP address..."
- Next in thread: Thorn: "Re: using grep to find IP address..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 May 2005 11:38:03 -0500
Greg Beeker wrote:
>
> balgach@gmail.com wrote:
>
>>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' ??
>
> ifconfig | grep '192.168' | awk '{print $2}' | awk -F. '{print $4}'
>
You never need grep and awk:
ifconfig | awk '/192.168/{print $2}' | awk -F. '{print $4}'
or even:
ifconfig | awk '/192.168/{split($2,f,".");print f[4]}'
Regards,
Ed.
- Next message: Ed Morton: "Re: using grep to find IP address..."
- Previous message: Ed Morton: "Re: Case statement"
- In reply to: Greg Beeker: "Re: using grep to find IP address..."
- Next in thread: Thorn: "Re: using grep to find IP address..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|