Re: Files not found
- From: John <nyrinwi@xxxxxxxxx>
- Date: Sat, 08 Mar 2008 08:34:16 -0600
Leslie Rhorer wrote:
I have a little puzzle I need to solve. I want to look in a directory and take action if no files less than 5 minutes old are found. If I were looking for files which are younger than five minutes, I could just do
find ./ -cmin -5 -exec do-something '{}' \;
Similarly, if I wanted it to take action if it finds files older than 5 minutes I could do
find ./ -cmin +5 -exec do-something '{}' \;
What I need, however, is to take action if there are no files less than 5 minutes old, regardless of whether there are files more than 5 minutes old or not.
Is there a reason why it has to be done by find?
Why not this Bash pattern?
files=$(find ./ -cmin -5 -print)
or if you prefer an array...
files=($(find ./ -cmin -5 -print))
You can then take whatever action you like; e.g.
if [ ${#files} -eq 0 ]; then ... # non array
This is all Bash stuff, consult the bash documentation for more info.
If you want to get fancy, you can look into inotify to setup a kind of watchdog, which sounds like what you may be looking for. I think Python has an inotify module.
John
.
- Follow-Ups:
- Re: Files not found
- From: Leslie Rhorer
- Re: Files not found
- From: Leslie Rhorer
- Re: Files not found
- References:
- Files not found
- From: Leslie Rhorer
- Files not found
- Prev by Date: How can spamassassin headers be filtered so that all or most of the spam messages, rather than mixed in with email, all or most go to a separate email file that can be checked for any false positives?
- Next by Date: source navigator NG (was Re: What to use to navigate around unfamiliar C++ code?)
- Previous by thread: Files not found
- Next by thread: Re: Files not found
- Index(es):