![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Can any one help me in getting all the files between any two given dates..
|
| Forum Sponsor | ||
|
|
|
|||
|
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 |
|
|||
|
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? |
|
|||
|
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.
|
|||
| Google The UNIX and Linux Forums |