Πέμπτη 4 Ιουλίου 2013

Simple commands to convert MAC addresses to Cisco format and vice versa

The common mac addres format is colon separated:
01:23:45:67:89:ab

Cisco format is dot separeted in three groups:
0123.4567.89ab

To convert from one format to another create the following scripts:

mactocisco
echo $1 | sed 's!\:!!g;s!\(....\)!\1.!g;s!.$!!' | tr "[:upper:]" "[:lower:]"

ciscotomac 
echo $1 | sed 's!\.!!g;s!\(..\)!\1:!g;s!:$!!'

example:

mymac:~ user$ ./ciscotomac 0123.4567.89ab

01:23:45:67:89:ab