On Thu, 2008-02-28 at 08:51 -0500, Toby Bluhm 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.
Jerry
There's multiple spaces in the output that cut is hitting - use tr to reduce them.
ifconfig | grep eth0 | tr -s ' ' ' ' | cut -d ' ' -f 5
/sbin/ifconfig | grep eth0 | awk '{ print $5 }'
for the lazy way or "man gawk" to see how to select and print and skip lines of no interest, eliminating the grep.
HTH