Thursday, January 14, 2010

How to convert a mac from Cisco/Foundry format to Unix format

I needed to associate servers to ports on our switches but the formats are different so I needed a way to convert them.

Here is a quick perl one line to go from Cisco/Foundry to Unix:
perl -ane '$_=~s/(..)\.?/\1:/g;$_=~s/:$//g; print $_'

An example:
echo 0019.b9f5.93f3 | perl -ane '$_=~s/(..)\.?/\1:/g;$_=~s/:$//g; print $_'
00:19:b9:f5:93:f3

No comments:

Post a Comment