从ifconfig输出中提取MAC地址的最佳方法? [英] Best way to extract MAC address from ifconfig's output?

查看:647
本文介绍了从ifconfig输出中提取MAC地址的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ifconfig的输出中提取MAC地址的最佳方法是什么?

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

示例输出:

bash-3.00# ifconfig eth0        
eth0      Link encap:Ethernet  HWaddr 1F:2E:19:10:3B:52    
          inet addr:127.0.0.66  Bcast:127.255.255.255  Mask:255.0.0.0    
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          ....
          ....

我应该使用剪切, AWK 或其他任何东西,它的优点和缺点是什么?一种方法胜过另一种方法.

Should I use cut, AWK or anything else, and what are the merits and demerits of one method over the other.

推荐答案

您可以在/sys/class/

cat /sys/class/net/*/address

专门针对eth0

cat /sys/class/net/eth0/address

这篇关于从ifconfig输出中提取MAC地址的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆