Need help to execute a script

Hi ,

I wrote below code to do filename change. I have a file named TEST2013_09_18_XX_XX_XX.csv and I want it to be TEST2013_09_17_XX_XX_XX.csv. i.e of last date
But when i am executing my script I am not getting expected output.

STAMP=`TZ=BST+24 date +%Y_%m_%d`
find /path of file/TEST`date +%Y_%m_%d`* -mtime -1 -exec echo {} \; > /path of log file/fof.log
file=TEST`date +%Y_%m_%d`*
echo $STAMP >> /path of log file/fof.log
echo $file >> /path of log file/fof.log
dltm=`echo $file|cut -d'_' -f4-`
echo $dltm >> /path of log file/fof.log
find /path of file/TEST`date +%Y_%m_%d`* -mtime -1 -exec mv -f {} /path of file/TEST$STAMP_$dltm \; 

Output I am getting as TESTXX_XX_XX.csv
Expected OUTPUT: TEST2013_09_17_XX_XX_XX.csv (I want todays date of filename to be changed to previous date)

Please note that XX_XX_XX are values and it keeps changing whenever file generated

Could you please help . Many thanks in advance

Try: ${STAMP}_ instead $STAMP_ (an underscore can be used in variable names)
It is also a good idea to put variable reference inside double quotes, for example:

"/path of file/TEST${STAMP}_$dltm"
2 Likes