The sys admin's daily grind: ifdata

Precision Interfacing

Article from Issue 148/2013
Author(s):

Script-friendly ifdata from the Moreutils package delivers absolutely precise network interface status information, with no need to extract individual values.

When I need to know whether a particular interface exists  – and, if so, what IP address and MTU it has – my script is inevitably bulky. I then bombard the results of ip addr show eth0, ifconfig, or iwconfig with grep, cut, and regular expressions until the requested information is chiseled out. In contrast, ifdata from the Moreutils package [1] solves my task elegantly. I can use parameters to control the ifdata output so that only the desired result appears, which is ideal for ongoing processing in a script. If I want to know whether a specific network interface exists, I can use:

ifdata -e eth0

The command produces no output, but the return value reveals whether the interface exists. In a script, this is very convenient if I want to branch:

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Charly's Column: ifdata

    Script-friendly ifdata from the Moreutils package delivers absolutely precise network interface status information, with no need to extract individual values.

  • Hot Stuff!

    This month, sys admin columnist Charly dumps the moreutils toolbox on his workbench and takes combine and vidir for a spin.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News