Convert IEEE802 MAC addresses to Cisco/etc format on text stream

I can’t even recall where/when/how I originally splatted this together but I just found it on an old server while cleaning out my home directory there.

``

[cstubbs@host bin]$ echo "abcdefg > > This should not be transformed: 00:gg:hh:xx:ll:yy > This should be transformed: 00:11:22:33:44:55 > > AYSD&YA&^DHASD(AS()DJ(AJSD(asdfasdgf > > " | perl ciscomac.pl abcdefg This should not be transformed: 00:gg:hh:xx:ll:yy This should be transformed: 0011.2233.4455 AYSD&YA&^DHASD(AS()DJ(AJSD(asdfasdgf [cstubbs@host bin]$

``

!/usr/bin/perl -w use strict; my $d = "[0-9A-Fa-f]"; my $dd = "$d$d"; while () { $_ =~ s/($dd):($dd):($dd):($dd):($dd):($dd)/$1$2.$3$4.$5$6/g; print $_; } # EOF

Author image
About colin-stubbs