Linux 如何剪切ifconfig以单独获取eth*详细信息?
我正在编写一个脚本来打印ifconfig的ethtool详细信息 示例输出应该来自ifconfig,如下所示:Linux 如何剪切ifconfig以单独获取eth*详细信息?,linux,bash,grep,ifconfig,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* root@bt#ethtool,其中arg1=eth* 要获得结果:-)您能帮我从ifconfig获
eth0
eth1
eth2
我试过使用下面的命令
root@bt# ifconfig | cut -d ":" -f 1
但却无法实现同样的目标
事实上,我需要得到这些eth*
并传入
root@bt# ethtool <arg1> where arg1=eth*
root@bt#ethtool,其中arg1=eth*
要获得结果:-)您能帮我从ifconfig获取裁剪吗 没有
$ awk -F: '$1 ~ "eth" { print $1 }' /proc/net/dev
eth0
使用
grep
和ifconfig
:
ifconfig | grep -o '^eth[0-9]\+'
或仅使用grep
:
grep -oP '^ *\Keth[0-9]+' /proc/net/dev