On Tuesday 19 June 2012 10:27:59 Mark Rogers wrote:
This works: mac=$(ifconfig eth0 | grep -Eo '..:..:..:..:..:..' | sed -e 's/://g')
.. but I'm sure there's a better way. Suggestions?
Also, if I have something like: echotemplate="This is my MAC: (MAC)" mac=$(ifconfig eth0 | grep -Eo '..:..:..:..:..:..' | sed -e 's/://g') echo $(echo $echotemplate | sed -e "s/(MAC)/$mac/")
.. is there a better way to do the substitution in the last line? I can't swap the top two lines around (one is a user-defined setting at the top of the script, the value of $mac is calculated in the body of the script), otherwise I would just use echo "This is my MAC: $mac" .. which would be nice and easy! But I'm using this as a learning exercise.
How about: /sbin/ifconfig eth0 | grep HWaddr | cut -d\ -f11 -- Stuart Bailey BSc (hons) CEng CITP MBCS LinuSoft (Managing Director) Linux Specialist & Software Developer ~~~~~~~~~~~~~~~~~~~~~~~ Phone: (0845) 658 3563 Direct: +44 (0) 1953 878162 Fax: +44 (0) 1603 858583 ~~~~~~~~~~~~~~~~~~~~~~~ http://www.linusoft.co.uk __________ Information from ESET Mail Security, version of virus signature database 7231 (20120619) __________ The message was checked by ESET Mail Security. http://www.eset.com