Well I use SUSE11 Linux machine, Is there is a single cmd which gives the eth number to which my IP is attched to ?
Ex:
<1035 sne-70 [u2see] :/home/u2see/nginrun/log>**ifconfig -a | grep addr**
eth0 Link encap:Ethernet HWaddr 00:25:9E:D4:7D:39
inet6 addr: fe80::225:9eff:fed4:7d39/64 Scope:Link
eth2 Link encap:Ethernet HWaddr 00:25:9E:D4:7D:3A
inet addr:192.168.100.70 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::225:9eff:fed4:7d3a/64 Scope:Link
eth3 Link encap:Ethernet HWaddr 00:25:9E:D4:7D:3B
inet6 addr: fe80::225:9eff:fed4:7d3b/64 Scope:Link
eth4 Link encap:Ethernet HWaddr 00:25:9E:D4:7D:3C
inet addr:**10.19.120.24** Bcast:10.19.120.255 Mask:255.255.255.0
inet6 addr: 2607:f0d0:1002:11::6/64 Scope:Global
inet6 addr: fe80::225:9eff:fed4:7d3c/64 Scope:Link
My IP is "10.19.120.24" And i need to get the output as eth4 by using single cmd.. What cmd i can use ?
You can use GNU awk:
ifconfig -a |awk -v RS="\n\n" '/inet addr:10.19.120.24 /{print $1}'