Skip to content

Instantly share code, notes, and snippets.

@o0-o
Last active September 7, 2023 20:02
Show Gist options
  • Save o0-o/eb7c9b045caac48479dd2a3946921639 to your computer and use it in GitHub Desktop.
Save o0-o/eb7c9b045caac48479dd2a3946921639 to your computer and use it in GitHub Desktop.
[MAC Addresses] Prints MAC addresses #Shell
# net_mac_addresses.sh
( # linux (NetworkManager)
nmcli -terse -fields GENERAL.HWADDR device show ||
# macos
networksetup -listallhardwareports ||
# linux/bsd
( ip address || ifconfig ) |
grep "ether"
) 2>/dev/null |
grep --only-matching --extended-regexp --regexp="([0-9a-fA-F]{2}\:){5}[0-9a-fA-F]{2}" |
grep --invert-match "00:00:00:00:00:00" |
grep --ignore-case --invert-match "ff:ff:ff:ff:ff:ff" |
sort |
uniq ||
exit 1 #failure
exit 0 #success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment