I am new to this forum and a novice at shell script. I am trying to write a script to determine each of the NIC configured on a linux system and its speed and Duplex. I came up with the following piece of code:
echo `ifconfig -a | grep eth > /home/a/nic.txt`
i=`awk -F, '{print NR}' /home/a/nic.txt`
for j in $i
do
nic"${j}"=`awk '{NR=$j} {print $1}' /home/a/nic.txt`
echo $nic"${j}"
if [ "$nic" == "" ];
then
exit 1
else
echo "SPEED & DUPLEX OF $nic$j:`ethtool $nic$j | grep -i duplex; ethtool $nic$j | grep -i speed`"
fi
done
But I am coming up with command not found for line in red. Why can't I declare a variable and increment just its count?
Thank you people....yes using arrays will be the best way of programming. But as I needed to get the system info, I ended up doing what Chubler_XL suggested and it works like a charm. Thank you Chubler_XL