Last active
June 20, 2020 18:30
-
-
Save Gronis/dc2c58223fe1ca53541b88bcca0241a4 to your computer and use it in GitHub Desktop.
Get the mac address for a certain host.
This file contains 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
#!/bin/bash | |
# | |
# Get the mac address for a certain host. | |
# | |
# Requires ping and arp tool. | |
# | |
# Usage: | |
# get_mac_address HOSTNAME | |
# | |
HOST=$1 | |
PATTERN='[0-9a-fA-F]*:[0-9a-fA-F]*:[0-9a-fA-F]*:[0-9a-fA-F]*:[0-9a-fA-F]*:[0-9a-fA-F]*' | |
ping -c 1 $HOST > /dev/null && arp -n $HOST | grep -io $PATTERN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment