0

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. ?

San
  • 223
  • 1
  • 6
  • 15

2 Answers2

1

No.

$ awk -F: '$1 ~ "eth" { print $1 }' /proc/net/dev
  eth0
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

With grep & ifconfig :

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

Or with only grep :

grep -oP '^ *\Keth[0-9]+' /proc/net/dev
Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223