Skip to content

Instantly share code, notes, and snippets.

@o0-o
Last active May 7, 2019 02:31
Show Gist options
  • Save o0-o/a95c501b7e626b0e4bfb767149e1a3dc to your computer and use it in GitHub Desktop.
Save o0-o/a95c501b7e626b0e4bfb767149e1a3dc to your computer and use it in GitHub Desktop.
[Network Interfaces] Prints network interfaces #Shell
# net_if.sh
( # linux
file /sys/class/net/* |
sed 's/.*\///g' ||
# macos
networksetup -listallhardwareports |
grep "Device:" |
awk '{ print $2 }' ||
# bsd
ifconfig -l ether |
tr " " "\n"
) 2>/dev/null ||
exit 1 #fail
exit 0 #success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment