Shell获取网卡Mac地址(grep、正则表达式)

版权声明:版权所有,转载须注明出处。 https://blog.csdn.net/Brouce__Lee/article/details/82660051
#!/bin/bash

#brief attain the Mac addr of netcard eth0. 
#author lee
#time 18.08.10


macaddr=`sudo ifconfig |grep HWaddr |head -n 1 | grep -o  "[a-f0-9A-F]\\([a-f0-9A-F]\\:[a-f0-9A-F]\\)\\{5\\}[a-f0-9A-F]"`
echo "Mac $macaddr"

猜你喜欢

转载自blog.csdn.net/Brouce__Lee/article/details/82660051
今日推荐