Created
May 30, 2018 06:33
-
-
Save benjyiw/a80a65608c4b1e37e9237d4e6e911255 to your computer and use it in GitHub Desktop.
Convert mac address to Cisco format (xxxx.xxxx.xxxx) and back (xx:xx:xx:xx:xx:xx)
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 | |
mac="$@" | |
if [[ ${mac} == ??:??:??:??:??:?? ]]; then | |
sed 's/\://;s/\:/./;s/\://;s/\:/./;s/\://' <<< ${mac} | |
elif [[ ${mac} == ????.????.???? ]]; then | |
sed 's/\.//g;s/\(..\)/\1:/g;s/:$//' <<< ${mac} | |
else | |
echo 'That does not appear to be a mac address, try harder' | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice