Losing quotes after redirection

Hello experts,

Pleas

I have written a shell script to build a parfile but I keep losing the quotes from query1 and query variables after the redirection.. How do I fix this ?

PARFILE=${EXPDP_BASE}/expdp_${DAY}.par

USERID=$(${ORACLE_BASE}/getpass.ksh SYSTEM opnlkp2.uk.ml.com)
DUMP=expdp_full_${ORACLE_SID}.${DATEMON}_%U
DUMPFILE=${DUMP}.dmp
LOGFILE=${DUMP}.log
DIRECTORY=EXP_DIR
FDATE=`date +%d-%b-%Y`
FTIME=`date +%H:%M:%S`
FLASHBACK_TIME="TO_TIMESTAMP('${FDATE} ${FTIME}','DD-Mon-YYYY HH24:MI:SS')"
CONTENT=ALL
SCHEMAS=ENDUR
PARALLEL=4
FILESIZE=3G
QUERY1=ENDUR.SIM_BLOB:"where sim_run_id in (select sim_run_id from sim_header where run_time >= trunc(SYSDATE -5) or trunc(run_time) in (trunc(sysdate,'mm')-1, trunc(add_months(sysdate,-1),'mm')-1))"
QUERY2="ENDUR.SIM_HEADER:"where run_time >= trunc(SYSDATE -5) or trunc(run_time) in ( trunc(sysdate,'mm')-1, trunc(add_months(sysdate,-1),'mm')-1)"
#find ${EXPDP_BASE}/*.gz -mtime +5 -exec rm -f {} \;

# Check if file already exists, if so, delete it

#if [ -f ${EXPDP_BASE}/${DUMPFILE}.gz ]
#then
#     rm ${EXPDP_BASE}/${DUMPFILE}.gz
#fi


echo "# Parameter created on ${FDATE}"           > $PARFILE
echo " "                                        >> $PARFILE
echo "userid=$USERID"                           >> $PARFILE
echo "dumpfile=$DUMPFILE"                       >> $PARFILE
echo "logfile=$LOGFILE"                         >> $PARFILE
echo "directory=$DIRECTORY"                     >> $PARFILE
echo "flashback_time=\"$FLASHBACK_TIME\""       >> $PARFILE
echo "content=$CONTENT"                         >> $PARFILE
echo "schemas=$SCHEMAS"                         >> $PARFILE
echo "parallel=$PARALLEL"                       >> $PARFILE
echo "filesize=$FILESIZE"                       >> $PARFILE
echo "query=${QUERY1}"                          >> $PARFILE
echo "query=${QUERY2}"                          >> $PARFILE

Try quoting the quotes inside QUERY1 like

QUERY1=ENDUR.SIM_BLOB:\"where sim_run_id in (select sim_run_id from sim_header where run_time >= ...

Otherwise the shell assumes the quotes are meant for it, and handles them itself.

The above line contains three double quote characters and gives a syntax error in my Shell. If you don't get a syntax error you may have another unmatched quote somewhere in the script. I'd remove the middle of the three.

It's not clear what you what value you want.