I am trying to find a script that will format a MAC address from say
001122334455 to 00:11:22:33:44:55
I found a post from a while back that used SED to do something similar however it only formats correctly if I used echo or a single line in the source file
Here is what im using as a reference:
=================================
sed 's!\-!!g;s!\.!!g;s!\(..\)!\1:!g;s!:$!!' /home/ntop/MAC.txt
00:26:0B:5C:AF:7A:
00:26:0B:5C:B0:67:
00:26:0B:5C:AD:5E:
00:26:0B:5C:B7:5F:
00:26:0B:5C:E2:97:
00:26:0B:5C:AD:21:
00:26:0B:5C:AD:F7:
00:26:0B:5C:AE:5C
=================
only the last MAC gets the final colon stripped out. If I use echo or a single line it works fine
==================
root@Netflow:~# echo 121234345656 | sed 's!\.!!g;s!\(..\)!\1:!g;s!:$!!'
12:12:34:34:56:56
===================
scripting is completely new to me so if there is something better then sed like php,etc I have no problems using that
Any pointers are appreciated!!
Thanks
-DP
001122334455 to 00:11:22:33:44:55
I found a post from a while back that used SED to do something similar however it only formats correctly if I used echo or a single line in the source file
Here is what im using as a reference:
=================================
sed 's!\-!!g;s!\.!!g;s!\(..\)!\1:!g;s!:$!!' /home/ntop/MAC.txt
00:26:0B:5C:AF:7A:
00:26:0B:5C:B0:67:
00:26:0B:5C:AD:5E:
00:26:0B:5C:B7:5F:
00:26:0B:5C:E2:97:
00:26:0B:5C:AD:21:
00:26:0B:5C:AD:F7:
00:26:0B:5C:AE:5C
=================
only the last MAC gets the final colon stripped out. If I use echo or a single line it works fine
==================
root@Netflow:~# echo 121234345656 | sed 's!\.!!g;s!\(..\)!\1:!g;s!:$!!'
12:12:34:34:56:56
===================
scripting is completely new to me so if there is something better then sed like php,etc I have no problems using that
Any pointers are appreciated!!
Thanks
-DP