Last active
September 7, 2023 20:02
-
-
Save o0-o/eb7c9b045caac48479dd2a3946921639 to your computer and use it in GitHub Desktop.
[MAC Addresses] Prints MAC addresses #Shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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