centos shell get ip mac address

——————————–mac————————

cat /sys/class/net/eth*/address

 

————————-mac—————————–

/sbin/ifconfig 
   | grep 'eth0' 
   | tr -s ' ' 
   | cut -d ' ' -f5

------------------ip--------------------------
/sbin/ifconfig 
   | grep '<inet>' 
   | sed -n '1p' 
   | tr -s ' ' 
   | cut -d ' ' -f3 
   | cut -d ':' -f2
--------------------------mac----------------
ifconfig | grep HWaddr | awk -F" " '{print $5}'

------------------------ip-------------------------
ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'