How can I tell if a file is older than 30 minutes from /bin/sh?

magol picture magol · Jan 5, 2010 · Viewed 90k times · Source

How do I write a script to determine if a file is older than 30 minutes in /bin/sh?

Unfortunately does not the stat command exist in the system. It is an old Unix system, http://en.wikipedia.org/wiki/Interactive_Unix

Perl is unfortunately not installed on the system and the customer does not want to install it, and nothing else either.

Answer

Schwern picture Schwern · Jan 5, 2010

Here's one way using find.

if test "`find file -mmin +30`"

The find command must be quoted in case the file in question contains spaces or special characters.