LinuxQuestions.org
Visit Jeremy's Blog.
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 09-06-2004, 04:15 PM   #1
Rv5
Member
 
Registered: Sep 2003
Distribution: RedHat9
Posts: 114

Rep: Reputation: 15
File Dates


What would the best way to be to get the file dates of files in the current directory through script? I want to archive all files older then say 30 days, and im not sure the best way to do it. any suggestions?
 
Old 09-06-2004, 06:01 PM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
There are many way

Code:
find $PWD -mtime 30
That will display all files in current directory recursivlly that have been modified one month ago (and before)

Last edited by Cedrik; 09-06-2004 at 06:03 PM.
 
Old 09-06-2004, 08:09 PM   #3
Rv5
Member
 
Registered: Sep 2003
Distribution: RedHat9
Posts: 114

Original Poster
Rep: Reputation: 15
yeah i had ideas like that, but how do i get at each file, to move it say into my backup directory?
 
Old 09-06-2004, 08:33 PM   #4
Rv5
Member
 
Registered: Sep 2003
Distribution: RedHat9
Posts: 114

Original Poster
Rep: Reputation: 15
could i use find and tar in conjuction say to archive all files 30 days or older?

something like

tar cv find -mtime 30

or something similar?
 
Old 09-06-2004, 08:39 PM   #5
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Try: tar cfv archive.tar `find -mtime 30`
 
Old 09-07-2004, 05:59 PM   #6
servnov
Member
 
Registered: Sep 2004
Distribution: Slackware 10.2
Posts: 276

Rep: Reputation: 30
update the time with 'touch' see time with 'ls -l'
 
  


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 07:34 PM
Trouble working with file dates cboxall Linux - Newbie 2 07-21-2005 11:11 AM
file dates digitalgravy Linux - General 2 01-20-2005 10:58 AM
Sorting a file containing dates subu_s Linux - General 2 06-03-2004 01:07 PM
File dates. vexer Programming 5 04-28-2004 12:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:31 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
Open Source Consulting | Domain Registration