The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-04-2004
thanuman thanuman is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 24
Lightbulb files between any two given dates

Can any one help me in getting all the files between any two given dates..
  #2 (permalink)  
Old 08-04-2004
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,715
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
  #3 (permalink)  
Old 08-06-2004
thanuman thanuman is offline
Registered User
  
 

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

Join Date: Mar 2006
Posts: 55
Lightbulb

This might be of interest to anyone reading this thread:

Thread

...thanks again all,

B14... aka... marky mark...
  #5 (permalink)  
Old 04-26-2007
jazjit jazjit is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 4
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
  #6 (permalink)  
Old 07-10-2007
Epiphone Epiphone is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 21
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?
  #7 (permalink)  
Old 07-11-2007
Epiphone Epiphone is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 21
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.
Sponsored Links
Closed Thread

Bookmarks

Tags
linux, linux commands, mtime

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0