[英]How to cut ifconfig to get eth* details alone?
我正在編寫一個腳本來打印ifconfig的ethtool詳細信息。
示例輸出應該來自ifconfig,
eth0
eth1
eth2
我嘗試使用以下命令,
root@bt# ifconfig | cut -d ":" -f 1
但是無法達到相同的目的。
實際上,我需要獲得這些eth*
並傳遞
root@bt# ethtool <arg1> where 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.