amh Asked: 2009-05-31 08:51:22 +0800 CST2009-05-31 08:51:22 +0800 CST 2009-05-31 08:51:22 +0800 CST How to restrict find command search to return only files modified before certain date? 772 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 linux find 4 Answers Voted Best Answer pgs 2009-05-31T09:00:24+08:002009-05-31T09:00:24+08:00 The command 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 Bernd Haug 2009-05-31T08:59:28+08:002009-05-31T08:59:28+08:00 ! -newermt '5/29/2009 23:59:00' should work on BSD; there will be a similar option on GNU. Xerxes 2009-05-31T09:01:41+08:002009-05-31T09:01:41+08:00 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). Matt Simmons 2009-05-31T09:03:16+08:002009-05-31T09:03:16+08:00 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
The command
find /path -mtime +7
will give you files older than 7 days, andfind ! -newer somefile
will give you files older than somefile. So...! -newermt '5/29/2009 23:59:00' should work on BSD; there will be a similar option on GNU.
You can place the
regex
at the end to speed up the command (place the fastest actions at the start, slowest at the end).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