I suggest instead of using backquotes it's a little better and certainly more readable to use the following format instead...
$( ... )
Now when I run your ifconfig command i do not get the mac address as output...
Code:
[david@david ~]# ifconfig | grep 'HWaddr '|cut -f 1
eth0 Link encap:Ethernet HWaddr 00:08:02:90:65:11
So I therefore came up with this...
Code:
[david@david ~]# ifconfig | awk '/HWaddr / { print $NF }'
00:08:02:90:65:11
The awk command first process the regex "/HWaddr /" ensuring only that line we want is grabbed (a bit like grep) and then "{ print $NF }" prints the last field in the line, delimited by spaces.
I also suggest you use quotes and braces to ensure variables are interpreted in the way you intend and so I end up with this...
Code:
#!/bin/sh
MAC=$(ifconfig | awk '/HWaddr / { print $NF }')
echo ${MAC}
cd /etc/sysconfig/network
mv "ifcfg-eth-id-${MAC}" 'ifcfg-eth0'
I haven't tested this but it should work ok
I note that if you have multiple nics configured this'll still likely not work as intended.
One last thing, as you didn't include the error message that the script produces when it fails it's a little more difficult to debug, however I suggest that you check you have permissions required to move the file, ie you have rwx permissions in /etc/sysconfig/network
I hope this helps