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

前端 未结 19 1892
面向向阳花
面向向阳花 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:09

    Use:

    ifconfig eth0 | grep HWaddr
    

    or

    ifconfig eth0 |grep HWaddr
    

    This will pull just the MAC address and nothing else.

    You can change your MAC address to whatever you want:

    ifconfig eth0 down,
    ifconfig eth0 hw ether (new MAC address),
    ifconfig eth0 up
    

提交回复
热议问题