I'd like to constrain the following search to only files with a modified date <= "2009-05-29 11:59:00"

find /path -name "*.sb" ! -name "*[^0-9]*.sb"  -type f -print

I'm using CentOS

link|improve this question

67% accept rate
feedback

4 Answers

up vote 3 down vote accepted

hmm, 'find /path -mtime +7' will give you files older than 7 days, and 'find ! -newer somefile' will give you files older than somefile. So...

touch -d "2009-05-29 11:59:00" timestampfile

find /path -name ".sb" ! -name "[^0-9]*.sb" ! -newer timestampfile -type f -print

link|improve this answer
or simply -mtime -1 ;) – Alex Jurkiewicz May 30 '09 at 17:01
Just out of curiosity, why would anyone mark down this answer as not helpful? – Matt Simmons May 30 '09 at 17:42
The '-newermt "DATE"' is a simpler/more elegeant way if you have GNU findutils installed. This is a little more portable across various UNIX versions, though it depends on the capabilities of your touch command. – pgs May 31 '09 at 2:41
feedback

! -newermt '5/29/2009 23:59:00' should work on BSD; there will be a similar option on GNU.

link|improve this answer
Its the same switch in GNU. – Kyle Brandt May 30 '09 at 17:19
feedback
find /path \
  -type f \
  ! -newermt "20090529 1159:00" \
  -regex "./[^0-9]*.sb$" \
  -print

You can place the regex at the end to speed up the command (place the fastest actions at the start, slowest at the end).

link|improve this answer
feedback

You want -mdate

find /path -name ".sb" ! -name "[^0-9]*.sb" -type f -print -mdate -2009-05-30

Here are a couple of examples:

http://www.softpanorama.org/Tools/Find/selecting_files_by_age.shtml
http://www.schuerig.de/michael/linux/snippets.html

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.