What is wrong with this code

I just wanted to assign the filename to a variable

filename="abc"
datestrng=`date +%Y%m%d`
filextn="txt"

"LOCAL_FILE"${i}=${filename}"_"${datestrng}"."${filextn}

 echo "LOCAL_FILE"$\{i\}

I get the following error on 2nd last line

ksh: LOCAL_FILE1=abc_20081114.txt: not found

Try changing
"LOCAL_FILE"${i}=${filename}""${datestrng}"."${filextn}
to
eval "LOCAL_FILE"${i}=${filename}"
"${datestrng}"."${filextn}

S.

Thanks.

Well, I don't get the error but
echo "LOCAL_FILE"${i}

does not display the file name
it displays LOCAL_FILE1 (when i=1), however I wanted it to dasplay abc_20081114.txt

thanks in advance

Hello mqasim,

You can subsequently print the content with:

eval echo \$LOCAL_FILE${i}

Anyway, I suspect what you are trying to do is using arrays. I do not know if your shell supports it, but if it does then an array alternative should work like this:

i=1
filename="abc"
datestrng=$(date +%Y%m%d)
filextn="txt"
LOCAL_FILE=${filename}"_"${datestrng}"."${filextn}
echo ${LOCAL_FILE}

Hope that works for you.

S.