|
Question : capture interface name from ifconfig in global variable
|
|
hello, in Solaris 10, how can I capture an interface name (not host, not ip address, just name) in a global variable that I can later reuse in a shell script. For example I need to capture the pcn0 from the following:
bash-3.00# ifconfig -a lo0: flags=2001000849CK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 pcn0: flags=201000843ST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2 inet 192.168.0.13 netmask ffffff00 broadcast 192.168.0.255 ether 0:c:29:9e:81:d9 lo0: flags=2002000849CK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1 inet6 ::1/128
Thanks,
Pepino125.
|
Answer : capture interface name from ifconfig in global variable
|
|
Run
ifconfig -a | awk -F: '/^[a-zA-Z0-9]+:/ && ! /lo[0-9]+:/ {print $1}'
Does it give you what you want? If so, use
InterfaceName=`ifconfig -a | awk -F: '/^[a-zA-Z0-9]+:/ && ! /lo[0-9]+:/ {print $1}'`
and $InterfaceName should have it.
|
|
|
|