Checking numeric expression in .ksh script

Gurus, Please need your help.

I'm saving a filetimestamp into $filetimestamp and
say....echo $filetimestamp gives 2015021612

I'm saving a cutoff_time into $cutoff_time
say....echo $cutoff_time gives 2015021514

now my requirement is to check if $filetimestamp is greater than $cutoff_time then we say "File to be zipped" else "The file does not exist".
This is how I coded.

if (( $filetimestamp -gt $cutoff_time ))
then
   echo "File to be zipped ",$file_name
else 
echo "The file does not exist"
exit
fi

Please correct me where I'm doing mistake as it is giving syntax error.

Thanks,
Srini

GNU find:

find /dir -cnewer cutoff.file

Try:

if ((filetimestamp > cutoff_time))
then
...

Hi,
How to get filetimestamp if file doesn't exist ?

Regards.

logic error in your question.

1 Like