Hi, I don't know if I got what you want. I think it is after giving an interface name the script saves this name and the associated mac address. Is that true?
Here is an example of a script that does that.
ifconfig -a |cut -f1 -d' '|grep -v '^$' > /tmp/net.$$ # Put all inet names in a tmp file.
echo -n "Choose your device:"
grep -q "$device" /tmp/net.$$ #Test if there is such a device
if [ $test1 -eq 0 ];then
ifconfig $device |grep -q HW # Test if this device has some Hardware address
if [ $test2 -eq 0 ];then
mac=`ifconfig $device |grep HW|cut -f2 -d'W'` # Get the mac
echo "The mac address of the interface $device is $mac"
echo The device $device has no mac address
echo "There is no such interface \"$device\"" >&2 #Send it to the error output
rm -f /tmp/net.$$ # removes the file before exit
rm -f /tmp/net.$$ # removes the file
Some corrections about your script:
intlist=ifconfig |grep HWaddr
the command must be between the accent `
intlist=`ifconfig |grep HWaddr`
intlist=$(ifconfig |grep HWaddr)