Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 CUT(!) 从 ifconfig 中仅提取 wlan0 的 MAC,方式如下:ifconfig eth0 | grep HWaddr | cut -d ' ' -f 11 为什么 ifconfig wlan0 | grep HWaddr | cut -d ' ' -f 11 不能以同样的方式工作?谢谢。
ifconfig wlan0 | grep -E -o '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'
编辑(更新为包括 cut 命令):
ifconfig wlan0 | grep -E -o '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | cut -f 1