Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 05-21-2004, 01:05 PM   #1
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 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!


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

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.


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
Senior Member
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
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......
find /var/vpopmail/domains -depth -atime +180 -exec ls -lh {} \;


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 > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:20 PM.

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