The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 12:01 PM
Move A File With Same Date,don't Change The Desitination Dir Date jee.ku2 UNIX for Dummies Questions & Answers 1 01-09-2008 09:42 AM
Changing Creation Date to a Prespecified Date of a File In Unix monkfan UNIX for Dummies Questions & Answers 4 11-28-2006 03:15 AM
Append a field to the end of each line of a file based on searching another file. ultimate Shell Programming and Scripting 2 03-29-2005 07:21 AM
Shell Script for searching files with date as filter kanakaraj_s Shell Programming and Scripting 3 05-14-2002 08:15 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-06-2008
Registered User
 

Join Date: Feb 2008
Posts: 6
searching a file by date...

It's possible to use "find" to search a file that was modified for example between 5/10/2004 and 7/11/2005? How can i do this? I saw there is option -mtime, but i don't understand how to use it in this case. Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-06-2008
HPAVC's Avatar
Registered User
 

Join Date: Feb 2008
Posts: 105
Quote:
Originally Posted by Kaminski View Post
It's possible to use "find" to search a file that was modified for example between 5/10/2004 and 7/11/2005? How can i do this? I saw there is option -mtime, but i don't understand how to use it in this case. Thanks
You can ...

-atime The time the file was last accessed
-ctime The time the file's status last changed
-mtime The time the file was last modified
-newer Newer than ...

touch -t 200410060000 /tmp/newerstart
touch -t 200511070000 /tmp/newerend
find . \( -newer /tmp/newerstart -a \! -newer /tmp/newerend \) -print



Unix Review > John & Ed's Miscellaneous find Tips
UNIX tips: Productivity tips
Reply With Quote
  #3 (permalink)  
Old 02-06-2008
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 674
Post

Quote:
Originally Posted by Kaminski View Post
It's possible to use "find" to search a file that was modified for example between 5/10/2004 and 7/11/2005? How can i do this? I saw there is option -mtime, but i don't understand how to use it in this case. Thanks
Code:
find /dir -type f -mtime +<days since 7/11/2005> -mtime -<days since 5/10/2004>
In other words:
-mtime -<days> looks for files newer than <days> old
-mtime +<days> looks for file older than <days> old
Reply With Quote
  #4 (permalink)  
Old 02-07-2008
Registered User
 

Join Date: Feb 2008
Posts: 6
the problem is that i need it for a script; it should be something like this:

#!/bin/bash
clear
read date #mm/dd/YYYY
find -option $date

it's possible to do this kind of things?
Reply With Quote
  #5 (permalink)  
Old 02-07-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,493
Change the date to a format touch can use, then add one day, and subtract one day
Code:
touch ./old -t   200801100000                # jan 10 2008 at one second after midnight
touch ./new -t  20080102359                 # jan 10 2008 23 hours 59
find /path/to/files \( -newer ./old -a ! -newer ./new\) -print
find can use the newer command to get an exact date. Change the time values to get what you want.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0