LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-15-2008, 04:14 PM   #1
Erik Mesoy
LQ Newbie
 
Registered: Mar 2008
Posts: 2

Rep: Reputation: 0
Trying to move files beyond cutoff date in subfolders and retain directory structure


Hello,

my logs from various forms of chat (IRC, MSN, ICQ, various) are now beginning to grow excessively in size. I decided that I wanted to move all files older than 7 days to an external storage device, and figured after a while that I probably wanted to use ls with a sort-by-time order and pipe this to mv to move the files, however, I'm coming up against two problems. First, I don't see how to get any sort of "cutoff" in ls when I sort by time; Second, I want the moved files to retain their directory structure (it's sorted by program and then by server and then by user) when I move them. So it may be that I want to use mv directly in some way; I'm not sure.

My clunky fallback is to move the entire superfolder containing all the logs and let it re-establish itself over time - this will be annoying in the first few days, where I can't easily view what I was talking to a person about last time, but that's a minor nuisance, so this isn't a particularly important problem.

Thanks in advance for any help,

Erik Mesoy.
 
Old 03-15-2008, 04:28 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
delete all files under /home/username which have last modified 30+ days ago...
Code:
find /home/username -mtime +30 -type f -exec rm {}\;

Last edited by acid_kewpie; 03-15-2008 at 04:31 PM.
 
Old 03-16-2008, 08:58 AM   #3
Erik Mesoy
LQ Newbie
 
Registered: Mar 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Great! I read find's man page and figured out pretty much everything I wanted to do. (Some ugly hacks involved, but hey. )

Thanks again,

Erik Mesoy.
 
  


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
Delete/move/copy files of specific date imsajjadali Red Hat 26 11-07-2013 11:34 PM
[SOLVED] rm files only - retain directory structure schneidz Programming 15 05-30-2013 04:08 PM
Advice? Best way to move files daily to a daily "date" named directory ziphem Linux - Newbie 2 04-15-2007 08:03 AM
backup from date keep directory structure secretlydead Linux - General 1 09-30-2005 03:51 PM
Program files and directory structure Carel Linux - Newbie 5 04-11-2001 10:57 AM


All times are GMT -5. The time now is 02:54 PM.

Main Menu
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