COUNTER='expr $COUNTER+1'
应该是
COUNTER=expr $COUNTER+1 或者 $(expr $COUNTER+1)