Linux Shell MAC address conversion convert with SED

Source: Internet
Author: User

Convert the 0024.b20b.693f address into a 00:24:b2:0b:69:3f

1. Dot-delimited

[Email protected] ~]# echo "0024.b20b.693f" | Sed-r ' s/\b (..) (..) \b/\1:\2/g;s/\./:/g '
00:24:b2:0b:69:3f

2. If the colon is separated, convert the 0024:b20b:693f to 00:24:b2:0b:69:3f last. Replaced by: can be removed;

[Email protected] ~]# echo "0024:b20b:693f" | Sed-r ' s/\b (..) (..) \b/\1:\2/g '
00:24:b2:0b:69:3f

Another matching method for 3.-r extended regular expressions

[Email protected] ~]# 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
[Email protected] ~]#

Linux Shell MAC address conversion convert with SED

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.