-
-
Save Neo2SHYAlien/02087d20362512ac2e69ca2fb12cb9ee 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 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
| #!/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' | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment