Question on using a variable in KSH

Hi all,

The below command tries to copy ".tgz" instead of "hello_test.tgz" -- It seems as if the underscore gets in the way. I tried with different ways of using quotes, with no luck, unfortunately...it's probably very simple, but may I ask how this would be done:

How would the below be fixed to copy "hello_test.tgz" instead of ".tgz"?

NAME=hello
cp $NAME_test.tgz /tmp/$NAME_test.tgz

Thanks very much
cg

By using:

cp -- "${NAME}_test.tgz" "/tmp/${NAME}_test.tgz"

Or just:

cp -- "${NAME}_test.tgz" /tmp

The problem is that underscore is a valid character in a variable name.
The shell is substituting $NAME_test not $NAME .
Surrounding the variable name with braces is the solution and many scripters do this routinely.
Following on from radolouv is is also conventional to put double quotes round strings whether or not it is mandatory.

NAME="hello"
cp "${NAME}_test.tgz" "/tmp/${NAME}_test.tgz"

Thanks so much...hm, for now on (no matter what--it looks cleaner anyway) I'll use double-quotation marks. Thanks so much for your help!