I am using this
DATE_FOLDER=$(date +"%b-%d-%a-%G")
FILENAME="HOME_$date1.tar.gz"
echo $BACKUP_DESTINATION/$DATE_FOLDER/$FOLDERNAME_$FILENAME
My output is
home/May-04-Wed-2011/HOME_May-04-0718PM-2011.tar.gz
but if I use -
instead of underscore _
echo $BACKUP_DESTINATION/$DATE_FOLDER/$FOLDERNAME-$FILENAME
then my ouput is correct
/home/May-04-Wed-2011/vmware-HOME_May-04-0717PM-2011.tar.gz
Why is that?
The problem is here :
HOME_$date1.tar.gz
and also here:_$FILENAME
. If you use_$
then the$
is escaped.Nevertheless you can do it with:
\\_$
. Then you escape the_
with the\
and the$
will be interpreted as you are used to it._
is a valid character for a variable name, and$FOLDERNAME_
doesn't exist.