LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-21-2004, 01:05 PM   #1
smeenge
LQ Newbie
 
Registered: May 2004
Posts: 3

Rep: Reputation: 0
Need help with some commands to prune files...


I posted this earlier in a forum that was incorrect category, so i will repost here...sorry.


I am an absolute Linux newbie, and am not even familiar enough with the find command and/or piping commands in order to figure this out.

I have a drive that needs periodic file pruning...here is the scenario:

I have a directory called /var/vpopmail/domains with thousands of folders and subfolders and subfiles within. I need to know a command that can help me:

1) Search the subdirectories to find files over a given size (say 20MB for example)

2) A command that will search the subdirectories and find/list all subdirectories that contain more than 10,000 files

3) A command that will search the subdirectories and delete all files that are older than 180 days.


Any help would be appreciated, i'm running out of disk space quickly!


Thanks.
jeff

FYI, RedHat 9
 
Old 05-21-2004, 04:44 PM   #2
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 388

Rep: Reputation: 52
  1. find /var/vpopmail/domains -size +20480k
  2. This will take a script, I think.
  3. find /var/vpopmail/domains -daystart -type f -ctime +180 -exec rm {} \;
Be very careful with number 3! Try it like this:

find /var/vpopmail/domains -daystart -type f -ctime +180 -exec ls -lh {} \;

(the rm is replaced with ls) first to verify that it lists the files you want deleted.

I started working on number 2, but sort of ran out of steam.

Lyle

edit: 320mb very wisely put /var/vpopmail/domains in the find command. I'm following suit.

Last edited by lyle_s; 05-21-2004 at 05:24 PM.
 
Old 05-21-2004, 05:10 PM   #3
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 47
well, using find command to search for file sizes is tricky..........
a file may be 850-bytes, BUT it takes up 900-bytes of space on the
drive........."find" goes by blocks of space, not just file size itself.

for #3...........try this also......
Code:
find /var/vpopmail/domains -depth -atime +180 -exec ls -lh {} \;
 
  


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
Prune Portage tree beaucoup Linux - Software 3 02-05-2005 04:03 PM
adding my own commands to rc files SizofreNICK Slackware 8 11-07-2004 02:30 AM
How to prune a print & file server to leave minimal services running wolfpeach Linux - Security 4 06-29-2004 06:35 AM
Using commands to output to files, how is this done? nro Linux - Newbie 3 11-11-2003 08:38 PM
How do I prune logs manually? Jonah W Linux - Newbie 1 08-29-2001 04:21 AM


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