Skip to content

Instantly share code, notes, and snippets.

@compor
Created February 25, 2013 15:17
Show Gist options
  • Select an option

  • Save compor/5030497 to your computer and use it in GitHub Desktop.

Select an option

Save compor/5030497 to your computer and use it in GitHub Desktop.
retrieves the name of the first ethernet interface
ifconfig -a | grep -i "link[ ]*encap[ ]*:[ ]*ethernet" | awk 'BEGIN{ iface="z" }
{ if( $1 ~ /^eth/ && iface > $1 ) iface=$1 }
END{ print iface }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment