I started writing ipaddr almost 20 years ago after the umpteenth time trying to parse ifconfig (and later ip) output in scripts. The original version was get only and Linux only.
It now supports Linux, QNX, and most BSDs. However, I rarely use BSD these days... so the set functions may not work 100%. I thought there might be somebody in the suckless community that finds it helpful. You need just the ip address of eth0? % ipaddr eth0 192.168.1.173 Nice simple output. All error output goes to stderr, so you can get just the IP or nothing. No awk/sed/cut needed. Also need the bitmask? % ipaddr -b eth0 192.168.1.173/24 Maybe the netmask instead? % ipaddr -im eth0 192.168.1.173 255.255.255.0 It can also be used to setup an interface: % ipaddr eth0 192.168.0.33/24 192.168.0.1 Will set the ip, netmask and default gateway. I could have also specified the netmask the old way: 255.255.255.0. You can see ipaddr.c on github: https://github.com/smaclennan/samtools/blob/master/ipaddr.c I can email the file to anybody who wants it. It is only 6k gzipped. Cheers, Sean