Created
August 12, 2016 14:27
-
-
Save spelcaster/2dff77811b737f13bc7fe6bda925b168 to your computer and use it in GitHub Desktop.
Get interface name and mac address grouped by vendor and device
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
#!/bin/bash | |
OLDIFS=$IFS | |
IFS=$'\n' | |
mapfile -t NIC_MODEL < <(lspci | grep -i ethernet | sed 's@[[:alnum:]]\+:[[:alnum:]]\+\.[[:alnum:]]\+\s*@@' | uniq) | |
IFS=${OLDIFS} | |
for (( i=0; i < ${#NIC_MODEL[@]}; i++ )) | |
do | |
echo ${NIC_MODEL[${i}]} | |
for addr in $(lspci | grep -i "${NIC_MODEL[${i}]}" | awk '{print $1}') | |
do | |
BUS=/sys/bus/pci/devices/$(ls /sys/bus/pci/devices | grep "${addr}") | |
for device in $(ls ${BUS}/net) | |
do | |
echo ${device} | |
cat ${BUS}/net/${device}/address | |
done | |
done | |
echo | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment