LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 07-15-2005, 05:37 PM   #1
billybobjoe1984
LQ Newbie
 
Registered: Jul 2005
Posts: 3

Rep: Reputation: 0
Using FIND to locate files created between certain dates


Hello everyone,

I am trying to make a script that will locate all files files matching a particular name "*x*" that were created between two dates so that I can then grep them for a particular string. I am currently using this script:

/bin/find ./ -ctime -31 -name "*x*" -exec /bin/cat {} ";" | /bin/grep y >> file

but my requirements have changed so I can't look for files created between last month and today, but rather between two past dates. Thanks for any assistance!
 
Old 07-15-2005, 06:18 PM   #2
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
There is no creation time for a file in UNIX systems
instead you have :
- time of last access
- time of last modification
- time of last status change

You surelly want time of last modification which is mtime
 
Old 07-15-2005, 06:48 PM   #3
billybobjoe1984
LQ Newbie
 
Registered: Jul 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Er, yeah -ctime isn't creation time but changed time, sorry for the misunderstanding. I was looking at mtime but it still doesn't look like it will support a range of dates either, only from the past till now. I need it to find files changed/modified between two past dates. Thanks for replying.
 
Old 07-15-2005, 07:08 PM   #4
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,617

Rep: Reputation: 136Reputation: 136
You could use -newer file and you touch a file
with the most ancient date and the other as :

1st date : 1/6/2005 12:00
2nd : 12/7/2005 12:00
Code:
touch -t 200506011200 first
touch -t 200507121200 last

find / -newer first ! -newer last
 
Old 07-16-2005, 11:30 AM   #5
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Quote:
Originally posted by billybobjoe1984
Er, yeah -ctime isn't creation time but changed time, sorry for the misunderstanding.
Just to clarify, -c is the time the inode entry was last changed, -m is the time the data in the file was last changed.
 
Old 07-21-2005, 04:26 PM   #6
billybobjoe1984
LQ Newbie
 
Registered: Jul 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by keefaz
You could use -newer file and you touch a file
with the most ancient date and the other as :

1st date : 1/6/2005 12:00
2nd : 12/7/2005 12:00
Code:
touch -t 200506011200 first
touch -t 200507121200 last

find / -newer first ! -newer last
Thanks, I'll give this a try!
 
Old 07-23-2005, 07:07 PM   #7
mlp68
Member
 
Registered: Jun 2002
Location: NY
Distribution: Gentoo,RH
Posts: 332

Rep: Reputation: 32
find takes multiple selectors

e.g. find files that were modified yesterday:

find . -mtime +1 -mtime -3

so, older than 1 day but younger than 3. Works with ctime, atime, mmin etc as well.

I think that's your ticket.

You can chain all kinds of selection statements like that.

mlp
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
file created/accessed dates plainkeyman Linux - General 4 10-27-2005 08:34 PM
cannot find a kernel, please locate one bobotoes Linux - Newbie 2 10-07-2004 07:15 PM
How do I find out when a directory was created? gumpish Linux - Newbie 1 09-29-2004 09:12 PM
how to find directories created in the last 30 mins? a128 Programming 1 02-05-2004 12:06 AM
how do i locate files? Pleasure Linux - Software 2 08-16-2003 09:42 AM


All times are GMT -5. The time now is 03:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration