Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何剪切ifconfig以单独获取eth*详细信息?_Linux_Bash_Grep_Ifconfig - Fatal编程技术网

Linux 如何剪切ifconfig以单独获取eth*详细信息?

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获

我正在编写一个脚本来打印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获取裁剪吗

没有

$ 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