Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-15-2008, 05: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


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, 05:28 PM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

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

Last edited by acid_kewpie; 03-15-2008 at 05:31 PM.
Old 03-16-2008, 09: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.


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

All times are GMT -5. The time now is 03:21 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