Best way to extract MAC address from ifconfig's output?

前端 未结 19 1649
面向向阳花
面向向阳花 2020-12-12 15:31

What is the best way to extract the MAC address from ifconfig\'s output?

Sample output:

bash-3.00# ifconfig eth0        
eth0      Link          


        
19条回答
  •  有刺的猬
    2020-12-12 16:19

    ifconfig en1 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' 
    
    • Replace "en1" with the name of the nic card "eth0" or remove altogether "en1" - easy and useful solution.

提交回复
热议问题