ifconfig gives following output:   eth0      Link encap:Ethernet  HWaddr 4c:87:0e:z3:e7:11                UP BROADCAST MULTICAST  MTU:1500  Metric:1              RX packets:0 errors:0 dropped:0 overruns:0 frame:0              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0              collisions:0 txqueuelen:1000               RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)    lo        Link encap:Local Loopback            inet addr:127.0.0.1  Mask:255.0.0.0          inet6 addr: ::1/128 Scope:Host          UP LOOPBACK RUNNING  MTU:65536  Metric:1          RX packets:35767 errors:0 dropped:0 overruns:0 frame:0          TX packets:35767 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0           RX bytes:5053027 (5.0 MB)  TX bytes:5053027 (5.0 MB)vmnet1    Link encap:Ethernet  HWaddr 60:80:66:m0:00:01            inet addr:192.168.139.1  Bcast:192.168.139.255  Mask:255.255.255.0          inet6 addr: fe80::250:56ff:fec0:1/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:0 errors:0 dropped:0 overruns:0 frame:0          TX packets:70 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)I presently need output like eth0   wlan0   127.0.0.1vmnet1  192.168.139.1so i run command  ifconfig | awk '/encap|inet addr/{  print }'but i am stuck now, as i need to combine 2 lines based on weather the next line contains the ipaddress pattern. Though shell script may do the trick ,But i need a simple single command solution.Any help will be appreciated.Though for loops are there in awk , but forward looking into next line , matching  & then printing on console is challenge for me .or is there  a simple command / flag for achieving such purpose ?route command seems to do the trick (awk field extraction!!) , but it doesnot list the inactive interfaces.
Printing interface-ipaddress through single command (piped)
ifconfig
finally found ifconfig based solution!String s=ifconfig | awk -F '[ :]' '/encap|inet addr/{ if($1 != \\ ){ print $1 \:\ $13 } else print $13 }'| awk -F \:\ '{print $1}'| awk '{  curr=$1 ; if(!system(\echo \$1\|grep ^[0-9]>/dev/null\)) {print prev \\\t : \ curr;prev=\\} else { if(prev!=\\) {print prev \\\t : not assigned\ }; prev=$1 }   }'explanation :root$ ifconfig | awk -F '[ :]' '/encap|inet addr/{ if($1 !=  ){ print $1 : $13 } else print $13 }'| awk -F : '{print $1}'eth0lo127.0.0.1vmnet1192.168.139.1vmnet8192.168.152.1wlan010.208.7.86so , i have piped the above output to another awk command:| awk '{  curr=$1 ; if(!system(echo $1|grep ^[0-9]>/dev/null)) {print prev \t :  curr;prev=} else { if(prev!=) {print prev \t : not assigned }; prev=$1 }   }'here , if i find two consecutive interface names, then i print the name of previous interface with custom messge not assigned  .if i get numeric  pattern in string then current string(ipaddress) along with the previous interface name is printed !