Please help to modify my script

Hi,

I have a script which connect to ATM's and pull two files from the ATM.
The which i try to pull is like
PIC20085200001*.JPG
First 7 digit consist of year montn and date as well
After todays execution i want to change the date to next date
I add few lines in the script but it is not working. The lines i added are

FILENAME1="PIC20085200001*.JPG"
DATES='date +%Y%m%d'
FILENAME="PIC_$DATES0001*.JPG"
FILENAME1=$FILENAME
echo $FILENAME1

Please help me to fix this
Thanks in advance
Renjesh

$ DATES='date +%Y%m%d'
$ FILENAME="PIC_$DATES0001*.JPG"
$ echo $FILENAME
PIC_*.JPG

Do you see the problem ?

Not working

Ugh. First you need to use bacticks (`) instead of single quotes to enclose the date command.

DATES=`date +%Y%m%d`

Next you should use ${DATES} instead of $DATES because else the shell will look for the var $DATES0001 in your code, which is not set and hence returns nothing.

FILENAME="PIC_${DATES}0001*.JPG"

Hi,

1.) Pls. make sure you are using back quotes for date command.
2.) The variable after $ sign is being considered as different one than the required so it's to be distinguished explicitly. Use the following one:

#!/bin/bash
FILENAME1="PIC20085200001*.JPG"
DATES=`date +%Y%m%d`
FILENAME="PIC_$DATES""0001*.JPG"
FILENAME1=$FILENAME
echo $FILENAME1

Regards,
Vinod.

instead of quotes use backticks for command substitution.

Thanks

Ya its working now
Thank u for helping me