如何切断ifconfig以获得eth *详细信息?

时间:2012-09-30 19:45:39

标签: linux bash grep ifconfig

我正在编写一个脚本来打印ifconfig的ethtool详细信息。

示例输出应该来自ifconfig,

eth0
eth1
eth2

我尝试使用以下命令,

root@bt# ifconfig | cut -d ":" -f 1 

但无法实现同样的目标。

实际上,我需要获取这些eth*并传入

root@bt# ethtool <arg1> where arg1=eth*

得到结果:-)你能不能帮我从ifconfig中获取作物。 ?

2 个答案:

答案 0 :(得分:1)

没有

$ awk -F: '$1 ~ "eth" { print $1 }' /proc/net/dev
  eth0

答案 1 :(得分:0)

grep&amp; ifconfig

ifconfig | grep -o '^eth[0-9]\+'

或仅使用grep

grep -oP '^ *\Keth[0-9]+' /proc/net/dev