使用sed实现mac地址显示风格变化

linux系统下的原始格式

root@pvesecondary:~# cat maclist.txt 
56:07:dc:7e:48:8b
be:e8:e3:b2:ba:68
ca:1e:a9:7d:63:44
7e:fe:58:80:28:68
06:78:6b:b5:e8:b9
fe:f4:0e:03:ec:73

处理成无分隔符格式

root@pvesecondary:~# sed 's/://g' maclist.txt
5607dc7e488b
bee8e3b2ba68
ca1ea97d6344
7efe58802868
06786bb5e8b9
fef40e03ec73

处理成华为交换机显示格式

root@pvesecondary:~# sed 's/://g' maclist.txt | sed 's/\(....\)/\1-/g;s/-$//'
5607-dc7e-488b
bee8-e3b2-ba68
ca1e-a97d-6344
7efe-5880-2868
0678-6bb5-e8b9
fef4-0e03-ec73

处理成IEE显示格式

root@pvesecondary:~# sed 's/://g' maclist.txt | sed 's/\(..\)/\1-/g;s/-$//'
56-07-dc-7e-48-8b
be-e8-e3-b2-ba-68
ca-1e-a9-7d-63-44
7e-fe-58-80-28-68
06-78-6b-b5-e8-b9
fe-f4-0e-03-ec-73

处理成思科交换机显示格式

root@pvesecondary:~# sed 's/://g' maclist.txt | sed 's/\(....\)/\1./g;s/.$//'
5607.dc7e.488b
bee8.e3b2.ba68
ca1e.a97d.6344
7efe.5880.2868
0678.6bb5.e8b9
fef4.0e03.ec73
声明:本文为原创,作者为 辣条①号,转载时请保留本声明及附带文章链接:https://boke.wsfnk.com/archives/1365.html
谢谢你请我吃辣条谢谢你请我吃辣条

如果文章对你有帮助,欢迎点击上方按钮打赏作者

最后编辑于:2024/6/15作者: 辣条①号

目标:网络规划设计师、系统工程师、ceph存储工程师、云计算工程师。 不负遇见,不谈亏欠!

暂无评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

arrow grin ! ? cool roll eek evil razz mrgreen smile oops lol mad twisted wink idea cry shock neutral sad ???

文章目录