LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-25-2005, 09:20 AM   #1
Koven
Member
 
Registered: Dec 2003
Distribution: Arch Linux
Posts: 49

Rep: Reputation: 15
find for an entire month


I want to know how can i use "find" to find some files created during a month. I know how can I get files from a day especifically but not during a month, i.e. all June.

Thanx for your time
 
Old 07-25-2005, 11:09 AM   #2
damienduff
Member
 
Registered: Feb 2004
Distribution: Etch
Posts: 117

Rep: Reputation: 15
hmm... use -mtime or -atime
modifiied time or accessed time.

find /directory -mtime 1
#1 = 1 day

see "man find"
 
Old 07-25-2005, 02:12 PM   #3
Koven
Member
 
Registered: Dec 2003
Distribution: Arch Linux
Posts: 49

Original Poster
Rep: Reputation: 15
I need to find a period of n days how can i do it?

REgards
 
Old 07-25-2005, 02:50 PM   #4
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
Find files older than 20 days but not older than 50:

find . -mtime +20 -mtime -50

If you want to make this more userfriendly you probably need to use perl which has very good fuctions to calculate dates so that you can easily convert something like 'June 05' to the arguments you need.
 
Old 07-26-2005, 10:49 AM   #5
Koven
Member
 
Registered: Dec 2003
Distribution: Arch Linux
Posts: 49

Original Poster
Rep: Reputation: 15
Now I dont understand about an error I get when I use -exec like this...

find /myown/route -mtime +20 -mtime -50 -exec tar -cvf /another/route/test.tar {}\;

find missing argument to -exec.

Thanks for your Time.
 
Old 07-26-2005, 02:11 PM   #6
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
It's complaining because you didn't leave a space after the '}'. But this isn't the way to do it, assuming you want to archive all those files from June. Try this:
Code:
find /your/path -mtime +20 -mtime -50 | tar -cf /path/to/dir/test.tar -T -
 
Old 07-26-2005, 08:56 PM   #7
Koven
Member
 
Registered: Dec 2003
Distribution: Arch Linux
Posts: 49

Original Poster
Rep: Reputation: 15
I'd like to know why that is note the way to do it. What's the main difference. I didn in a correct way like this...

find /path -mtime +m -mtime -n -exec tar -rvf /another/path {} \;

Thanks for your time.

Regards
 
Old 07-26-2005, 10:06 PM   #8
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
ok, it'll work with the -r (append) option. Originally, you had a -c which would have overwritten test.tar each time. But, that wasn't my point. I was just thinking in terms of efficiency (calling tar each time you encountered a file, etc.)

[edit] Also take a look at the gzip man page under the section entitled "ADVANCED USAGE". (It's not your situation exactly, since you're not compressing.)

Last edited by Berhanie; 07-26-2005 at 10:16 PM.
 
  


Reply



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
transform month number to month name in php ALInux Programming 1 11-09-2005 10:45 AM
Starting day of month, month length chrisk5527 Programming 2 03-03-2004 04:03 PM
back after a month nakkaya General 3 06-22-2003 11:22 PM
ip traffic mb/month thorwil Linux - Networking 2 04-23-2003 08:33 AM
musings for the month gui10 General 4 04-06-2002 09:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:24 AM.

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
Open Source Consulting | Domain Registration