#!/usr/bin/perl #eth0 Link encap:Ethernet HWaddr 00:20:18:8C:CF:38 # UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 # RX packets:28996528 errors:146 dropped:225 overruns:0 frame:0 # TX packets:17386158 errors:0 dropped:0 overruns:0 carrier:0 # collisions:1188496 txqueuelen:100 # RX bytes:2863396931 (2730.7 Mb) TX bytes:1792216541 (1709.1 Mb) # Interrupt:10 Base address:0xf000 $iface = shift or die("usage: ifcfg \n"); open(IFCFG, "/sbin/ifconfig $iface |") or die("Where is ifconfig? : $!\n"); while() { if (/RX bytes:(\d+?)\s.+?TX bytes:(\d+)/) { print("$1\n$2\ninterface $iface\nunused\n"); } }