Created
October 16, 2019 02:25
-
-
Save scue/c12610d1318168fca96565c91802d35e to your computer and use it in GitHub Desktop.
Linux 获取物理网卡名字(Linux list physical network interfaces by shell script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list physical network interfaces | |
ls -l /sys/class/net/ | egrep -v 'virtual|total' | awk '{print $NF}' | awk -F/ '{print $NF}' | |
# list physical network interfaces mac addresses | |
for i in $(ls -l /sys/class/net/ | egrep -v 'virtual|total' | awk '{print $NF}' | awk -F/ '{print $NF}'); do ip addr show dev $i | awk '/ether/{print $2}'; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: