Determine if the content of a file/directory exist for more than 2 hours

Viewed 103

I try to create a bash script that determine if the content of a .txt file or a directory is older than 2 hours and then return it to me, where hour should be a configurable variable. What I have till now is not working unfortunately. Can you help :) ?

#!/bin/sh

#Determine how old is the file
old=`find /opt/import/dev -ctime -20m`


If [ -n $old ]
then
echo "old files found:"
echo /n $old
1 Answers

To get the list of files modified less than $hour hours ago, you have to use next arguments for the command find:

((min = hour * 60))
old=$( find /opt/import/dev -cmin -$min )
Related