find command to find files of a certain date

find command to find files of a certain date

Post by Rob » Sat, 12 Apr 2003 06:49:38



How do I use "find" to print out filenames (including paths) of files with a
date I specify?  e.g. I want to show all files on my server that have a date
of "26 Feb".
 
 
 

find command to find files of a certain date

Post by Darren Dunha » Sat, 12 Apr 2003 08:03:55



> How do I use "find" to print out filenames (including paths) of files with a
> date I specify?  e.g. I want to show all files on my server that have a date
> of "26 Feb".

If you require 'find' to do it, then you'll have to use temporary
files.  Something like this should work...

# touch -m 02260000 /tmp/file1
# touch -m -t 02262359.59 /tmp/file2
# find <dir> -newer /tmp/file1 ! -newer /tmp/file2 -ls

Other options would be to...
1) Write a small script in perl.  This would potentially allow you to
   parse the date you give to it, and would not require temporary files.
2) Parse the find output of all files for the date.  Something like...

# find <dir> -ls | grep "26 Feb"

--

Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

 
 
 

find command to find files of a certain date

Post by Matt » Sat, 12 Apr 2003 16:56:42



> How do I use "find" to print out filenames (including paths) of files with
a
> date I specify?  e.g. I want to show all files on my server that have a
date
> of "26 Feb".

With GNU find and date you could write a small script such as:

#!/bin/ksh
integer date=$(date +%j)
integer target_date=$(date -d "${1:-today}" +%j)
exec find -daystart -mtime $((date-target_date))

This takes a suitably quoted target date (e.g. '26 Feb') as its only
argument. You'll need to modify it to handle previous years' dates, or
further options, tests, etc. for find. Of course, if you can work out the
difference yourself, you can just type:

find -daystart -mtime 44 (or whatever)

HTH

Matt M

 
 
 

find command to find files of a certain date

Post by Mik » Mon, 14 Apr 2003 08:45:42



Quote:> How do I use "find" to print out filenames (including paths) of files with
a
> date I specify?  e.g. I want to show all files on my server that have a
date
> of "26 Feb".

You might want to check the find ./ -m <days>... command also. It allows you
to find things modified <days> ago, + or - can be added for <more than/less
than days>