The following works correctly for me to get the number of such files.
ls $LGNAME* | wc -l
If you wanted them sorted in reverse timestamp order, this should work fine:
ls -rt $LGNAME*
To answer the more general question, you could do something like this. I am not sure exactly what modifications you would need to make to make it work in a non-bash shell though.
LGNAME="/var/log/msgbak"
count=$(ls $LGNAME* | wc -l)
if [ "$count" -gt 10 ]; then
ls $LGNAME* | head -n 1 | xargs rm
fi