1748018 Members
3783 Online
108757 Solutions
New Discussion юеВ

Re: find with -mtime

 
SOLVED
Go to solution
Brad Marks
Super Advisor

find with -mtime

I've gone through past threads and don't find what I'm experiencing (which is really confusing to me).

I want to see all files modified in the past 24 hours in the directory /usr2/p.
When I use:
find /usr2/p -mtime 0 -exec ll {} ';'
I get every file in the directory.

When I use:
find /usr2/p -mtime 1 -exec ll {} ';'
I get files modified between 48 hours ago and 24 hours ago, not within the past 24 hours.

Here's the machine I'm doing this on:
HP-UX fki B.11.11 U 9000/800

Help would be really appreciated; points will be awarded!
Thanks!
It's not impossible -- it'll just cost more...
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor
Solution

Re: find with -mtime

Hi Brad:

First, confine your search to *files* so you can examine the real candidates and not the contents of a directory that matched the time criteria:

# find /usr2/p -type f -mtime 0 -exec ls -l {} +

Not only did I add '-type f' but I terminated the '-exec' with a '+" character. This is much more efficient than using the semicolon. Multiple arguments are bundled and passed to the process to be 'exec'ed akin to using a pipe and 'xargs'. Your processor will love you.

As for the treatment by 'find()' of '-mtime 1' see Dennis's commentary in this thread:

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1271016

Regards!

...JRF...
Patrick Wallek
Honored Contributor

Re: find with -mtime

Try this:

find /usr2/p -mtime -1 -type f -exec ll {}+
Brad Marks
Super Advisor

Re: find with -mtime

Without the -type f, /usr2/p itself was found, then the ll {} caused all of /usr2/p to be listed. After the entirety of /usr2/p is listed, then the qualifying files in /usr2/p were listed.
Whew!

Thanks, James
It's not impossible -- it'll just cost more...
Dennis Handly
Acclaimed Contributor

Re: find with -mtime

>Without the -type f, /usr2/p itself was found, then the ll {}

If you want to see directories, you can use "ll -d" so their content isn't listed.