Skip to content

Instantly share code, notes, and snippets.

@x42en
Created April 26, 2019 09:22
Show Gist options
  • Save x42en/fc1ea5239b8c344af28e3bdcf577f6ab to your computer and use it in GitHub Desktop.
Save x42en/fc1ea5239b8c344af28e3bdcf577f6ab to your computer and use it in GitHub Desktop.
Bash ninja to retrieve network interfaces name
# List all interfaces
ip a | grep "^[[:digit:]]:[[:space:]]" | awk '{print $2}' | sed s/://g
# List all interfaces except loopback
ip a | grep "^[[:digit:]]:[[:space:]]" | grep -v 'lo:' | awk '{print $2}' | sed s/://g
# List all connected interfaces
ip a | grep "^[[:digit:]]:[[:space:]]" | grep -F 'state UP' | awk '{print $2}' | sed s/://g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment