Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 09-06-2004, 04:15 PM   #1
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
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
There are many way

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
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
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
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
Registered: Sep 2004
Distribution: Slackware 10.2
Posts: 276

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


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 > Forums > Non-*NIX Forums > Programming

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

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