[CentOS] GRabbing MAC address

Thu Feb 28 22:03:28 UTC 2008
Wojtek Pilorz <wpilorz at bdk.pl>

On Thu, Feb 28, 2008 at 08:13:17AM -0600, Les Mikesell wrote:
> Jerry Geis wrote:
> >I am trying to grab the mac address for eth0 on centos 5.1 with
> >
> >ifconfig | grep eth0 | cut -d ' ' -f 5 and I dont get anything.
> >
> >What am I not doing right?
> >
> >ifconfig | grep eth0 | cut -d ' ' -f 1 gives me eth0 but anything else 
> >like -f 2, -f 3 etc
> >I get nothing.
> >
> 
> If sed had been invented first, we wouldn't need grep.
> 
> ifconfig |sed -n -e 's/eth0.*\(..:..:..:..:..:..\)/\1/p'
> 
> -- 
>   Les Mikesell
>    lesmikesell at gmail.com
Specifying eth0 as ifconfig parameter also would be better
once there is eth0:0, eth0:1, etc.
Otherwise multiple lines would be returned.

Wojtek