I have some lines like [ 17.440000] eth0: XYZCOMPANY ABC4353 802.11 Wireless Controller
[ 17.540000] eth1: XYZCOMPANY ABC4353 802.11 Wireless Controller
[ 17.640000] eth2: XYZCOMPANY ABC4353 802.11 Wireless Controller
I need to get eth0, eth1, eth2 into a variable in shell script. As you can notice all the other lines like XYZCOMPANY ABC4353 remains constant.but interface name is keep changing. I need to get those interface names into a variable.
Thanks!
This will show
eth
andwlan
addresses with any number of digits:If you don't need
wlan
you can remove the alternate. I'm not sure if theeth
driver uses hex, but you can change "digit" to "xdigit" if it does and you need to allow for more than 10 intefaces.That is to have something like "eth0: eth1: eth2" in your variable
This solution should be working too:
var=$(dmesg | grep "eth[0-9]: [A-Za-z0-9 ]* 802.11 Wireless Controller" | awk '{ print substr($3,0,5) }')