LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Tags used in this thread
Popular LQ Tags ,

Reply
 
Thread Tools
Old 03-15-2008, 05:14 PM   #1
Erik Mesoy
LQ Newbie
 
Registered: Mar 2008
Posts: 2
Thanked: 0
Trying to move files beyond cutoff date in subfolders and retain directory structure


[Log in to get rid of this advertisement]
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.
Erik Mesoy is offline  
Tag This Post
Reply With Quote
Old 03-15-2008, 05:28 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 33,330
Thanked: 182
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 05:31 PM..
acid_kewpie is offline  
Tag This Post
Reply With Quote
Old 03-16-2008, 09:58 AM   #3
Erik Mesoy
LQ Newbie
 
Registered: Mar 2008
Posts: 2
Thanked: 0

Original Poster
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.
Erik Mesoy is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 22 02-01-2008 07:41 PM
Advice? Best way to move files daily to a daily "date" named directory ziphem Linux - Newbie 2 04-15-2007 09:03 AM
rm files only - retain directory structure schneidz Programming 9 11-27-2005 02:08 PM
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


All times are GMT -5. The time now is 06:08 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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration