find command's newer option
Posted on 2005-05-11
I have a directory user1 in which files get written continuously.
I want to list the "new" files that are in this directory based
on a reference file using find command.
Here's what I have been trying:
while read file
find . \( -name $file -a newer $ref_file \) -print
done < list
Here "list" is a text file which contains list of all files in the specified directory.
The problem is that whenever i create(touch) the $ref_file through the script
the find command does not find files newer than $ref_file while as if I do NOT
create the file ($ref_file) through the script and create it manually before executing the script, new files are found.
Basically, since the ref_file is being created just after any new file is written in the directory
the find command "fails" to recognize any new file. I have tried to "sleep 60" before creating the
reference file but of no avail.
BTW, in the find command how new is newer -is it based on seconds,minutes etc.
Any help would be highly appreciated.