![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| IP Address not found in ifconfig/netstat | Isax50 | IP Networking | 1 | 02-08-2009 09:32 AM |
| script to get IP address from ifconfig | speedy3k | Shell Programming and Scripting | 9 | 12-31-2008 12:54 AM |
| how to grep only IP address of e1000g0 using ifconfig -a | solaix14 | Shell Programming and Scripting | 1 | 11-03-2008 03:28 PM |
| ifconfig: ce401001: bad address | sag71155 | IP Networking | 2 | 06-19-2008 12:08 PM |
| ifconfig bad address | ppass | SUN Solaris | 2 | 03-11-2005 07:59 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
extracting the ip address from ifconfig
Hi I am trying to create a script extracting the IP provided by ifconfig. I tried with grep + awk but I am returned more than I need. Code:
/sbin/ifconfig eth0 | grep "inet addr:" | awk '/inet addr:/ { print $2 }'
and returns Code:
addr:10.15.1.64 How can I remove "addr:" string? Thanks in advance |
|
||||
|
Quote:
Code:
A bit modification :
/sbin/ifconfig eth0 | awk -F":" '/inet addr:/ { print $2 }'
|
|
||||
|
Code:
/sbin/ifconfig eth0 | grep "inet addr:" | awk '/inet addr:/ { print $2 }' | cut -d":" -f2
or Code:
/sbin/ifconfig eth0 | grep "inet addr:" | awk '/inet addr:/ { print $2 }' | awf -F":" '{print $2}'
Last edited by Franklin52; 09-29-2009 at 10:48 AM.. Reason: Please use code tags! |
|
||||
|
Quote:
![]() ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|