egrep.sh

#!/bin/bash
#Description:filter MAC using egrep

ifconfig | egrep "[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}"

验证:

[root@logstash ~]# sh egrep.sh 
        ether 02:42:0e:ad:48:a7  txqueuelen 0  (Ethernet)
        ether 02:42:d2:90:29:4a  txqueuelen 0  (Ethernet)
        ether 00:0c:29:ed:c6:f8  txqueuelen 1000  (Ethernet)
        ether 00:0c:29:ed:c6:f8  txqueuelen 0  (Ethernet)
        ether 00:0c:29:ed:c6:f8  txqueuelen 0  (Ethernet)
        ether d2:b1:69:12:53:22  txqueuelen 0  (Ethernet)
[root@logstash ~]#