I have a set of variables (M1 to M20) with values 1 or 0 in them. And i want to loop through them and echo a message when one is 1.
#!/bin/sh
for r in {1..20}
do
if [ ${"M$r"} -eq 1 ]
then
col=`expr 150 \+ $r`
echo " M"$r" is here: "$col" "
fi
done
I can't figure out the substitution.