File test commands with variable file name

Hi there

I have the following code

SDFFILE_SRC=$BACKEND_DIR/$SDFFILE_MIN_tar
SDFFILE_DST=$SIM_DIR/$SDFFILE_MIN
if [[ (-e "$SDFFILE_DST"  && ("$SDFFILE_SRC" -nt "$SDFFILE_DST")) || (! -e "$SDFFILE_DST") ]]
....
....
....
fi

Simply I need to check if $SDFFILE_SRC isa newer than $SDFFILE_DST or $SDFFILE_DST does not exist then execute the IF Body.
Although the the condition is not true, the IF body is executed.
Is there a problem with using file test commands with variable file names ?

Thanks,

if [[ ! -e "$SDFFILE_DST" || "$SDFFILE_SRC" -nt "$SDFFILE_DST" ]]; then

Does not work either.

I found the problem. In the IF condition body I extract the file $SDFFILE_SRC to $SDFFILE_DST. The extracted file reserves the modification date of the source compressed file.
For example the $SDFFILE_SRC compressed file modification date is @ 11:30am. Whenever I extract it, the extracted file reserves the time 11:30am.
How can I make the extracted file ignore the source file date ?

---------- Post updated at 05:35 PM ---------- Previous update was at 05:30 PM ----------

I found this option
--keep-newer-files
Used for tar upon extraction which keeps newer files. I removed the if condition as it's useless now.

Thanks

2 Likes