日期:2014-05-16  浏览次数:20605 次

shell获取文件

eth0      Link encap:Ethernet  HWaddr 00:15:17:5E:5F:6C
          inet addr:192.168.0.33  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::215:17ff:fe5e:5f6c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1144872507 errors:0 dropped:0 overruns:0 frame:0
          TX packets:885101111 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1136432969365 (1.0 TiB)  TX bytes:656963257836 (611.8 GiB)
          Memory:b8820000-b8840000

eth1      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:16436  Metric:1
          RX packets:1564202548 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1564202548 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:5000
          RX bytes:1397446681227 (1.2 TiB)  TX bytes:1397446681227 (1.2 TiB)


怎样使用sed实现提取eth0,txqueuelen:1000的数据组合成:eth0txqueuelen:1000
同样的组合成:eth1txqueuelen:5000。


------解决方案--------------------
ifconfig -a 
------解决方案--------------------
 sed ':a;$!N;s/\n / /;ta;P;D' 
------解决方案--------------------
 sed -r 's/^([^ ]+).*(txqueuelen:[^ ]+).*/\1 \2/'