[opensuse] find between two dates?
I have a question for 'find' experts. I want to find all files between two specific dates, and was able to do it with -mtime, but wonder if there's an easier way to do it. I used: find . -type f -daystart -mtime +LATER -a -mtime -EARLIER -exec ls -l {} \; where LATER is 3 for 5 Sept 2009 and EARLIER is 6 for 2 Sept 2009, to find files modified between 3 and 4 September. It works, but it feels cumbersome and the same values can't be used tomorrow to locate files for the same dates. Am I missing something obvious? -- Jim
On Tuesday September 8 2009, Jim Cunning wrote:
I have a question for 'find' experts. I want to find all files between two specific dates, and was able to do it with -mtime, but wonder if there's an easier way to do it. I used:
find . -type f -daystart -mtime +LATER -a -mtime -EARLIER -exec ls -l {} \;
where LATER is 3 for 5 Sept 2009 and EARLIER is 6 for 2 Sept 2009, to find files modified between 3 and 4 September.
It works, but it feels cumbersome and the same values can't be used tomorrow to locate files for the same dates. Am I missing something obvious?
Well, it's a bit circuitous, but find has a -newer predicate that uses the mod time of a specific file as the time reference. This combined with the "touch" command's ability to set a file's mod time to an arbitrary date would allow you to write a script that creates a couple of temp files, touches them to the appropriate beginning and ending dates and uses find's -newer (and a negated -newer) to get the net effect you're looking for. Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Jim Cunning wrote:
I have a question for 'find' experts. I want to find all files between two specific dates
The "-newerXY" option does what you want. For example find /bin -newermt 1/1/2008 -a ! -newermt 1/1/2009 will find everything in /bin that was modified in 2008. Seems to be a GNU extension, though. Regards nordi -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tuesday September 8 2009, nordi wrote:
Jim Cunning wrote:
I have a question for 'find' experts. I want to find all files between two specific dates
The "-newerXY" option does what you want. For example
Interesting. I had to look that one up. It's clearly the way to go for Jim's purposes.
find /bin -newermt 1/1/2008 -a ! -newermt 1/1/2009
will find everything in /bin that was modified in 2008. Seems to be a GNU extension, though.
Regards nordi
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tuesday 08 September 2009 17:19:29 Randall R Schulz wrote:
On Tuesday September 8 2009, nordi wrote:
Jim Cunning wrote:
I have a question for 'find' experts. I want to find all files between two specific dates
The "-newerXY" option does what you want. For example
Interesting. I had to look that one up. It's clearly the way to go for Jim's purposes.
find /bin -newermt 1/1/2008 -a ! -newermt 1/1/2009
will find everything in /bin that was modified in 2008. Seems to be a GNU extension, though.
Regards nordi
Randall Schulz
Interesting indeed..... and thanks. Unfortunately, it's not supported on openSUSE 10.3 on my laptop [GNU find version 4.2.31], but I can use it on my office Gentoo system [find (GNU findutils) 4.4.0] -- Jim
participants (3)
-
Jim Cunning
-
nordi
-
Randall R Schulz