There are some requirements where you may need to get the network related information and handle them in your script, it may come often or rarely but irrespective of it, you will choose certain standard ways. For example if you want to list the number of network interface or check if an interface is up or not or let say you want to know the MAC Address if the interface, you will mostly use ifconfig command and parse the information. You will use pipes, sed, awk, grep, regex and other filter tools. You dont need all these things if you use the command ifdata.

According to the manpage ifdata it says ” get network interface info without parsing ifconfig output”

#apt-get install moreutils

$ifdata Usage: ifdata [options] iface -e Reports interface existence via return code -p Print out the whole config of iface -pe Print out yes or no according to existence -pa Print out the address -pn Print netmask -pN Print network address -pb Print broadcast -pm Print mtu -ph Print out the hardware address -pf Print flags -si Print all statistics on input -sip Print # of in packets -sib Print # of in bytes -sie Print # of in errors -sid Print # of in drops -sif Print # of in fifo overruns -sic Print # of in compress -sim Print # of in multicast -so Print all statistics on output -sop Print # of out packets -sob Print # of out bytes -soe Print # of out errors -sod Print # of out drops -sof Print # of out fifo overruns -sox Print # of out collisions -soc Print # of out carrier loss -som Print # of out multicast -bips Print # of incoming bytes per second -bops Print # of outgoing bytes per second

$ifdata -pn wlan0 255.255.255.0

$ifdata -pm wlan0 1500

$ifdata -e wlan0 echo $? 0 $ifdata -e wlan5 echo $? 1

For more information about this useful command

man ifdata