Linux shell mac 地址转换 convert with sed
Linux shell mac 地址转换 convert with sed
Linux shell mac 地址转换 convert with sed
把 0024.b20b.693f 地址 转换成 00:24:b2:0b:69:3f
1.点号分隔的
[root@bkjia-mpc ~]# echo "0024.b20b.693f" | sed -r 's/\b(..)(..)\b/\1:\2/g;s/\./:/g'
00:24:b2:0b:69:3f
2.若是冒号分隔的,把 0024:b20b:693f 转换成 00:24:b2:0b:69:3f 最后的. 替换成:可以去掉了;
[root@bkjia-mpc ~]# echo "0024:b20b:693f" | sed -r 's/\b(..)(..)\b/\1:\2/g'
00:24:b2:0b:69:3f
3.-r 扩展正则表达式的另一种匹配方法
[root@bkjia-mpc ~]# echo "0024.b20b.693f" | sed -r 's/\b([0-9af]{2})([0-9a-f]{2})\b/\1:\2/g;s/\./:/g'
00:24:b20b:69:3f
[root@bkjia-mpc ~]#
Shell编程浅析
Linux Shell参数替换
Shell for参数
Linux/Unix Shell 参数传递到SQL脚本
Shell脚本中参数传递方法介绍
Shell脚本传递命令行参数
Linux Shell 通配符、转义字符、元字符、特殊字符
本文永久更新链接地址:
评论暂时关闭