Convert Linux MAC Format to Cisco MAC Format at the Linux CLI

AllLinux
Just a helpful tip for those annoying translations between the Linux MAC Formats (DE:AD:BE:EF:CA:FE) and the Cisco MAC Formats (dead.beef.cafe).

Grabbing the ARP table normally looks like this:
arp -an | grep -vi 'incomplete'





You can pipe in the ‘sed’ (stream editor) command to remove the colons and replace them with periods every 4 characters instead, and use the ‘tr’ (translator) command to change the case from upper to lower:
arp -an | sed -e 's/\(..\):\(..\)/\1\2/g' | tr ':[:upper:]' '.[:lower:]'
Now you can copy the output for use in Cisco devices.

You can of course still grep after the sed and tr commands to provide specific outputs:
arp -an  | sed -e 's/\(..\):\(..\)/\1\2/g' | tr ':[:upper:]' '.[:lower:]' | grep 10.10.83.159


SecureCRT Button
If you’re lazy (or efficient) like me, you’ll just add this to your button bar in SecureCRT, and you’ll need to use double up on the backslashes ‘\’ as a single backslash is seen as an escape character.
arp -an | sed -e 's/\\(..\\):\\(..\\)/\\1\\2/g' | tr ':[:upper:]' '.[:lower:]'



Categories: All, Linux