首页 / 操作系统 / Linux / Linux shell mac 地址转换 convert with sed
Linux shell mac 地址转换 convert with sed把 0024.b20b.693f 地址 转换成 00:24:b2:0b:69:3f1.点号分隔的[root@linuxidc-mpc ~]# echo "0024.b20b.693f" | sed -r "s/(..)(..)/1:2/g;s/./:/g"
00:24:b2:0b:69:3f2.若是冒号分隔的,把 0024:b20b:693f 转换成 00:24:b2:0b:69:3f 最后的. 替换成:可以去掉了;[root@linuxidc-mpc ~]# echo "0024:b20b:693f" | sed -r "s/(..)(..)/1:2/g"
00:24:b2:0b:69:3f3.-r 扩展正则表达式的另一种匹配方法[root@linuxidc-mpc ~]# echo "0024.b20b.693f" | sed -r "s/([0-9af]{2})([0-9a-f]{2})/1:2/g;s/./:/g"
00:24:b20b:69:3f
[root@linuxidc-mpc ~]# Shell编程浅析 http://www.linuxidc.com/Linux/2014-08/105379.htm Linux Shell参数替换 http://www.linuxidc.com/Linux/2013-06/85356.htmShell for参数 http://www.linuxidc.com/Linux/2013-07/87335.htmLinux/Unix Shell 参数传递到SQL脚本 http://www.linuxidc.com/Linux/2013-03/80568.htmShell脚本中参数传递方法介绍 http://www.linuxidc.com/Linux/2012-08/69155.htmShell脚本传递命令行参数 http://www.linuxidc.com/Linux/2012-01/52192.htmLinux Shell 通配符、转义字符、元字符、特殊字符 http://www.linuxidc.com/Linux/2014-10/108111.htm本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-12/110448.htm