![]() |
|
|
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 |
| Handling variable inputs | yhacks | High Level Programming | 1 | 05-23-2008 07:04 AM |
| read n number of inputs | er_aparna | Shell Programming and Scripting | 14 | 07-27-2006 12:35 PM |
| Validating inputs from a file | sendhilmani123 | Shell Programming and Scripting | 1 | 05-10-2006 06:49 AM |
| Inputs from a file | sendhil | Shell Programming and Scripting | 4 | 02-01-2006 05:48 AM |
| Multiple Inputs | douknownam | Shell Programming and Scripting | 4 | 05-25-2004 01:15 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Please give your inputs !!!!
I am trying to extract two fields from the output of ifconfig command on one of my sun server . The output looks like :
root@e08k18:/tmp/test# ifconfig -a lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2 inet 10.177.4.61 netmask ffffff00 broadcast 10.177.4.255 groupname ipmp0 ether 0:3:ba:6c:7f:2e I require output as field1 filed2 for all the interfaces ...but when I try la0 127.0.01 ce0 10.177.4.61 # ifconfig |awk -F ":" {print $1 $3)' However I am not getting the required output. Any clue in this regard will be of great help. Thanking you in advance. |
|
||||
|
Quote:
------------- #!/bin/sh ifconfig -a | awk -F":" '{print $1}' | awk 'BEGIN {x = 0} { if (x<2) { printf("%s ",$0) x=x+1 } if (x==2) { printf("\n") x = 0 } }' | awk '{print $1, $3}' ------------- |
|
||||
|
Thanks for your reply I have tried this :-
ifconfig -a | awk -F":" '{print $1}' | awk 'BEGIN {x = 0} { if (x<2) { printf("%s ",$0) x=x+1 } if (x==2) { printf("\n") x = 0 } }' | awk '{print $1, $3}' and it gives the output as :- ce2 172.16.0.129 ce6 172.16.1.1 clprivnet0 172.16.193.1 ce0 10.177.4.61 ce0:1 10.177.4.70 ce0:2 10.177.4.66 ce0:3 10.177.4.67 ce0:4 10.177.4.65 ce4 10.177.4.62 ce3 10.177.224.80 ce0 10.177.4.61 Thanks once again !!!!! |
|
||||
|
Quote:
ifconfig -a | awk -F":" '{print $1}' | paste - - | awk '{print $1, $3}' |
|
||||
|
Quote:
|
|
|||||
|
Please use a title that describes your problem. Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|