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
Files and dates mastachef UNIX for Dummies Questions & Answers 1 12-03-2007 10:12 AM
Copy only files created between two dates r_sethu UNIX for Dummies Questions & Answers 2 07-27-2007 12:24 AM
list exe files modified before certain dates fremont UNIX for Dummies Questions & Answers 2 05-25-2007 06:29 AM
transferring files using ftp but mantaining the dates 435 Gavea Shell Programming and Scripting 4 07-23-2006 08:48 AM
Remove files by dates dman110168 UNIX for Dummies Questions & Answers 1 10-24-2000 09:21 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-04-2004
Registered User
 

Join Date: Mar 2004
Posts: 24
Stumble this Post!
Lightbulb files between any two given dates

Can any one help me in getting all the files between any two given dates..
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-04-2004
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,841
Stumble this Post!
try something like this:

Code:
olddate="200407010001"
newdat="200407312359"
touch -t $olddate ./tmpoldfile
touch -t $newdat ./tmpnewfile
find /path/to/directory -type f  -newer a ./tmpoldfile ! -newer  a ./tmpnewfile
the "-newer a " means access time, you can use "-newer m " for modify time
Reply With Quote
  #3 (permalink)  
Old 08-05-2004
Registered User
 

Join Date: Mar 2004
Posts: 24
Stumble this Post!
Thanks for the help... It is working as per expectations..
Is it possible to do this with sed /awk /fgrep...
Reply With Quote
  #4 (permalink)  
Old 06-15-2006
Registered User
 

Join Date: Mar 2006
Posts: 55
Stumble this Post!
Lightbulb

This might be of interest to anyone reading this thread:

Thread

...thanks again all,

B14... aka... marky mark...
Reply With Quote
  #5 (permalink)  
Old 04-26-2007
Registered User
 

Join Date: Apr 2007
Posts: 4
Stumble this Post!
if i add this in a shell script it gives error stating the following:

date: bad conversion
date: bad conversion
find: cannot access tmpoldfile

can you suggest on how to go about putting it inside a script alltogether
Reply With Quote
  #6 (permalink)  
Old 07-10-2007
Registered User
 

Join Date: Jun 2007
Posts: 21
Stumble this Post!
I have a load of logfiles,

Jul 5 07:03 MSG_sdfd_dsfsdf_sdfsdfsdf_070705_123116.gz
Jul 6 08:03 MSG_sdf_sdfsdfsd_sdfsdf_070705_181255.gz
Jul 6 14:03 MSG_sdf_sdfsdf_sdfdsfsdf_070705_224108.gz
Jul 6 20:03 MSG_sdf_sdfsdf_sdfdsfsd_070706_034803.gz
Jul 7 01:03 MSG_sdf_sdfsdf_sdfsdfdsf_070706_065025.gz
Jul 7 06:03 MSG_sdf_sdfsdf_sdfsdf_070706_081903.gz
Jul 8 10:03 MSG_sdf_sdfdsf_sdfsdf_070706_092214.gz
Jul 8 17:03 MSG_sdf_sdfsdf_sdfsdf_070706_144128.gz

I want to search through them using the bold text below which is the file creation date as the starting date/time and the file last modified date as the end date/time

MSG_sdf_sdfsdf_sdfsdf_070706_144128.gz

Ive been using the code already in this thread to search by 2 modified date/time. But how can I combine the 2?
Reply With Quote
  #7 (permalink)  
Old 07-11-2007
Registered User
 

Join Date: Jun 2007
Posts: 21
Stumble this Post!
So I'm using the tmpfile solution as already discussed in this thread. But What I'm currently doing is using 2 Find commands, 1 which finds everything with mtime in between the 2 temp files and the 2nd to find the files by the name I want.

But sometimes I get duplicate entries, cos sometimes files exist which have the mtime and file name I'm looking for. So I have to not select them. Then I combine the results from both finds and display the result.

But I cant figure out how to do this with 1 find

Code:
@results = `find . -type f  -newer ./tmpoldfile ! -newer ./tmpnewfile`;

@results2 = `find . \\( -name *$h$i$b$c* -o -name *$h2$i2$b2$c2* \\)`;

My attempt at combining the 2, but I need to a not and expression, does that exist?
#@results3 = `find . -type f \\( \\( -newer ./tmpoldfile ! -newer ./tmpnewfile \\) -a \\( -name *$h$i$b$c* -o -name *$h2$i2$b2$c2* \\) \\) -ls`;



foreach $name (@results)
{

        if ($name =~ m/(^.*)([0-9][0-9])([0-9][0-9])([0-9][0-9])_([0-9][0-9])([0-9][0-9])([0-9][0-9])(.*$)/)

        {
                        $creation_date = "20$2/$3/$4";
                        $creation_time = "$5:$6:$7";
        }

        if ("$creation_date $creation_time" ge "$date $time" && "$creation_date $creation_time" le "$date2 $time2") {


        } else {
                push(@logfile, $name);
 }

}

        foreach $name (@results2)

 {
                if ($name =~ m/(^.*)([0-9][0-9])([0-9][0-9])([0-9][0-9])_([0-9][0-9])([0-9][0-9])([0-9][0-9])(.*$)/)

                {
                        $creation_date = "20$2/$3/$4";
                        $creation_time = "$5:$6:$7";
                }

        if ("$creation_date $creation_time" ge "$date $time" && "$creation_date $creation_time" le "$date2 $time2") {

                push(@logfile, $name);

        } else {


        }

Then I print and work with the results.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux, mtime

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:58 PM.


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