Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!gatech!mcnc!rti!dg-rtp!dg-rtp.dg.com!rice From: rice@dg-rtp.dg.com (Brian Rice) Newsgroups: comp.unix.questions Subject: Re: Listing files bet. two specified dates Message-ID: <1990Oct24.181321.23205@dg-rtp.dg.com> Date: 24 Oct 90 18:13:21 GMT References: <9220005@hpldsla.sid.hp.com> <2162@sixhub.UUCP> Sender: usenet@dg-rtp.dg.com (Usenet Administration) Reply-To: rice@dg-rtp.dg.com Followup-To: comp.unix.questions Organization: Data General Corporation, Research Triangle Park, NC Lines: 40 In article <2162@sixhub.UUCP>, davidsen@sixhub.UUCP (Wm E. Davidsen Jr) writes: |> In article <9220005@hpldsla.sid.hp.com> |> manoj@hpldsla.sid.hp.com (Manoj Joshi) writes: |> | Alternatively, has anyone written a utility that will list out all |> | files that have their modification times between two specified times. |> | for eg., all files between Oct 1 1990 and Oct 10 1990. The hardest part of this problem is the date arithmetic. If the problem were to print all files modified between, say, 10 and 40 days ago, the solution would be simple (I've tested this to some extent, but it's still more or less off the top of my head): #!/bin/sh # mbetween path bound_1 bound_2 # Argument 1 is taken to be the root of the directory tree to # search. Argument 2 is one bound (in days), and argument # 3 is the other bound (in days). find $1 -mtime -$2 -print > /tmp/mbetween.$$ find $1 -mtime -$3 -print >> /tmp/mbetween.$$ sort /tmp/mbetween.$$ > /tmp/mbetween2.$$ uniq -u /tmp/mbetween2.$$ rm -f /tmp/mbetween.$$ /tmp/mbetween2.$$ exit 0 If you had a date arithmetic package (didn't one just get posted somewhere recently?) which supplied a Julian date function, you could provide a front end to mbetween (this is pseudocode): #!/bin/sh # better_mbetween path date_1 date_2 mbetween $1 `expr `jdate `date`` - `jdate $2`` \ `expr `jdate `date`` - `jdate $3`` -- Brian Rice rice@dg-rtp.dg.com +1 919 248-6328 DG/UX Product Assurance Engineering Data General Corp., Research Triangle Park, N.C.