Variable value not being fetched in the filename..

Hi,

In the code below, the $DD1, $DD2, $MM1, $MM2 are not fetching the values. Can anybody tell me where have i made wrong.

Shift_date.sh is a script which gives the previous date if we give the current date in the format YYYYMMDD and +/- how many days past/future.. Like Shift_date.sh 20080531 -2 gives an output as 20080529.

At last echo $DD1 is giving the correct value. But i need to get that in Pockets_$MM1-$DD1_to_$MM2-$DD2_data.txt..
Is it because of meta characters being used? Please Help..

#!/bin/ksh

currweekday=`date '+%u'`

currdate=`date '+%Y%m%d'`

((n1 = currweekday + 7))
((n2 = currweekday + 1))

DD1=$(ksh Shift_date.sh $currdate -$n1 | cut -c7-8)
MM1=$(ksh Shift_date.sh $currdate -$n1 | cut -c5-6)
DD2=$(ksh Shift_date.sh $currdate -$n2 | cut -c7-8) 
MM2=$(ksh Shift_date.sh $currdate -$n2 | cut -c5-6)

echo Pockets_$MM1-$DD1_to_$MM2-$DD2_data.txt

echo $DD1

Thanks,
RRVARMA

Hi,

Also the above script is giving value only for $MM1 and $MM2, if i assign the values directly.. ie,

DD1=01
MM1=05
DD2=14
MM2=06

echo Pockets_$MM1-$DD1_to_$MM2-$DD2_data.txt

echo $DD1

I get a result like this..

Pockets_05-06-.txt
01

The problem is that i'm not supposed to change the file name format. It should include the meta characters as well.. :frowning:
Please help..

Thanks,
RRVARMA

Change

to

echo Pockets_${MM1}-${DD1}_to_${MM2}-${DD2}_data.txt

Hi fpmurphy,

Thanks very much.. Its working now.. :slight_smile:

Thanks,
RRVARMA