How to cut ifconfig to get eth* details alone?
问题 I'm writing a script to print ethtool details of ifconfig. Sample output should be from ifconfig is like, eth0 eth1 eth2 I have tried using below command, root@bt# ifconfig | cut -d ":" -f 1 But could not able to achieve the same. Actually, i need to get these eth* and pass in root@bt# ethtool <arg1> where arg1=eth* to get results :-) can you please help me to get crop from ifconfig. ? 回答1: With grep & ifconfig : ifconfig | grep -o '^eth[0-9]\+' Or with only grep : grep -oP '^ *\Keth[0-9]+'