Skip to content

Instantly share code, notes, and snippets.

@nilox94
Last active February 18, 2019 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilox94/27f372c6d4a596754643b4c98202fc86 to your computer and use it in GitHub Desktop.
Save nilox94/27f372c6d4a596754643b4c98202fc86 to your computer and use it in GitHub Desktop.
Commands to list network interfaces and specifically wired and wireless interfaces
#!/bin/sh
function net-interfaces(){
echo `ip -c=never addr | gawk 'match($0, /[[:digit:]]+: ([[:alnum:]]+):/, m) { print m[1] }'`
}
function wireless() {
echo `ip -c=never addr | gawk 'match($0, /[[:digit:]]+: (w[[:alnum:]]+):/, m) { print m[1] }'`
}
function ethernet() {
echo `ip -c=never addr | gawk 'match($0, /[[:digit:]]+: (e[[:alnum:]]+):/, m) { print m[1] }'`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment