Quick question about using "find" command.

Quick question about using "find" command.

Post by vector sigm » Sun, 16 Jun 2002 03:24:57



Hi all:

  Just a quick question about using "find." The "-mtime" or "-ctime" option
  seems to use "equal" for comparison. "Find -mtime 2 /home" gives files
  that are modified "equal" to 2 days ago.

  But I want to find all files in my home directory that are CREATED since
  60 days ago. I can write a script, but it is inconvenient. Is there a way
  to make "find" do "equal to or less than" 60 days?

  Thanks for any hints.

vector sigma

 
 
 

Quick question about using "find" command.

Post by Drew Laws » Sat, 22 Jun 2002 01:27:59




Quote:>Hi all:

>  Just a quick question about using "find." The "-mtime" or "-ctime" option
>  seems to use "equal" for comparison. "Find -mtime 2 /home" gives files
>  that are modified "equal" to 2 days ago.

>  But I want to find all files in my home directory that are CREATED since
>  60 days ago. I can write a script, but it is inconvenient. Is there a way
>  to make "find" do "equal to or less than" 60 days?

Add a + or - to the time.
  find . -mtime -3 -print

will print the names of all files less than 3 days old.  I think
(I've never used it) that "+3" wound get all those over 3 days old.

I'm not sure whether either of those include files which are exactly
3 days old.

--
Drew Lawson            |  Though it's just a memory,


 
 
 

Quick question about using "find" command.

Post by Erik Nygre » Sat, 22 Jun 2002 05:17:47



> Hi all:

>   Just a quick question about using "find." The "-mtime" or "-ctime" option
>   seems to use "equal" for comparison. "Find -mtime 2 /home" gives files
>   that are modified "equal" to 2 days ago.

>   But I want to find all files in my home directory that are CREATED since
>   60 days ago. I can write a script, but it is inconvenient. Is there a way
>   to make "find" do "equal to or less than" 60 days?

I think you will find that "find /home -mtime +60" gives files in
/home that are not modified for the last 60 days.
"find /home -mtime -60" should give you files that are modified the
last 60 days.
Now, if you still won't RTFM, this is a shortcut ;-)
find(1):
...
     All primaries which take a numeric argument allow the number to be pre-
     ceded by a plus sign (``+'') or a minus sign (``-'').  A preceding plus
     sign means ``more than n'', a preceding minus sign means ``less than n''
     and neither means ``exactly n''.
...

--
Erik Nygren
e r i k { a t } s w i p { d o t } n e t
Linux - If you hate Microsoft, FreeBSD - If you love Unix