Your script syntax is valid bash and good.
Possible causes for the failure:
Your bash
is not really bash but ksh
or some other shell which doesn't understand bash's parameter substitution. Because your script looks fine and works with bash.
Do ls -l /bin/bash
and check it's really bash and not sym-linked to some other shell.
If you do have bash on your system, then you may be executing your script the wrong way like: ksh script.sh
or sh script.sh
(and your default shell is not bash). Since you have proper shebang, if you have bash ./script.sh
or bash ./script.sh
should be fine.