Confirming Syntax - IF statement.

Hi All,

Has been a while since I was last on, so I hope everyone has been doing fine. :wink:

Would like to know if the below IF statement syntax is correct for a ksh environment. It's been pushed into live as someone had deleted the development copy(!); not withstanding that, the statement now won't be called/executed until May 5th. So if there is any obvious issues seen, I'll have time to fix.

Any/all feedback appreciated.

Cheers,
Cameron

if [ \( "${MKT}"="PU" -o "${MKT}"="PH" \) -a "${FILETYPE}"="PAY" ] ; then
  cp ${FTP_DIR}/${MKT}-${DOR}.BANKHOLIDAY \
     ${FTP_ARC}/${MKT}-${DOR}-${FILETYPE}.BANKHOLIDAY
else
  mv ${FTP_DIR}/${MKT}-${DOR}.BANKHOLIDAY \
     ${FTP_ARC}/${MKT}-${DOR}-${FILETYPE}.BANKHOLIDAY
fi

This way is clearer for me:

if [ "${MKT}"="PU" -o "${MKT}"="PH" ] && [ "${FILETYPE}"="PAY" ]
then
     cp ${FTP_DIR}/${MKT}-${DOR}.BANKHOLIDAY \
     ${FTP_ARC}/${MKT}-${DOR}-${FILETYPE}.BANKHOLIDAY
else
  mv ${FTP_DIR}/${MKT}-${DOR}.BANKHOLIDAY \
     ${FTP_ARC}/${MKT}-${DOR}-${FILETYPE}.BANKHOLIDAY
fi

Thanks for the reply Klashxx.

I assume that if I reverse the logic, the result will still remain the same ??

if [ "${FILETYPE}"="PAY" ] && [ "${MKT}"="PU" -o "${MKT}"="PH" ]

Just thinking of others who will need to read it (more pedantic than anything else I guess). :wink:

Yep , it will produce the same result.