# Checking numeric expression in .ksh script

**URL:** <https://community.unix.com/t/checking-numeric-expression-in-ksh-script/350452>\
**Category:** Shell Programming and Scripting\
**Created:** [February 16, 2015, 11:04am UTC](https://community.unix.com/t/checking-numeric-expression-in-ksh-script/350452 "2015-02-16T11:04:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thummi9090](https://community.unix.com/letter_avatar/thummi9090/32/6_22734026db12803ebb3e059622ac3534.png) [@thummi9090](https://community.unix.com/u/thummi9090)\
**Post date:** [February 16, 2015, 11:04am UTC](https://community.unix.com/t/checking-numeric-expression-in-ksh-script/350452/1 "2015-02-16T11:04:57Z")

</div>

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.

```nohighlight
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

---

<div class="post-metadata">

**Author:** ![agent.kgb](https://community.unix.com/user_avatar/community.unix.com/agent.kgb/32/9333_2.png) [@agent.kgb](https://community.unix.com/u/agent.kgb)\
**Post date:** [February 16, 2015, 11:13am UTC](https://community.unix.com/t/checking-numeric-expression-in-ksh-script/350452/2 "2015-02-16T11:13:43Z")

</div>

GNU find:

```nohighlight
find /dir -cnewer cutoff.file

```

---

<div class="post-metadata">

**Author:** ![fpmurphy](https://community.unix.com/user_avatar/community.unix.com/fpmurphy/32/110_2.png) [@fpmurphy](https://community.unix.com/u/fpmurphy)\
**Post date:** [February 16, 2015, 11:20am UTC](https://community.unix.com/t/checking-numeric-expression-in-ksh-script/350452/3 "2015-02-16T11:20:58Z")

</div>

Try:

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

```

---

<div class="post-metadata">

**Author:** ![disedorgue](https://community.unix.com/user_avatar/community.unix.com/disedorgue/32/22261_2.png) [@disedorgue](https://community.unix.com/u/disedorgue)\
**Post date:** [February 16, 2015, 11:23am UTC](https://community.unix.com/t/checking-numeric-expression-in-ksh-script/350452/4 "2015-02-16T11:23:58Z")

</div>

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

Regards.

---

<div class="post-metadata">

**Author:** ![agent.kgb](https://community.unix.com/user_avatar/community.unix.com/agent.kgb/32/9333_2.png) [@agent.kgb](https://community.unix.com/u/agent.kgb)\
**Post date:** [February 16, 2015, 11:27am UTC](https://community.unix.com/t/checking-numeric-expression-in-ksh-script/350452/5 "2015-02-16T11:27:24Z")

</div>

> [@disedorgue](#):
>
> Hi,  
> How to get filetimestamp if file doesn't exist ?

logic error in your question.
