Delete all files within a folder?

prettydumb

Active Member
Aug 25, 2007
35
0
56
is this the correct linux format to delete all files within the /cur/ folder without deleting cur?

I have an account which has 10 gig of email and I want to delete all emails.

rm /home/user/mail/cur/*
 
Last edited:

nyjimbo

Well-Known Member
Jan 25, 2003
1,133
1
168
New York
10 GIG is alot and it might not work on a single wildcard delete. You might have to cd to /home/user/mail/cur/ and then do a "ls" to see what the file names are and delete them in chunks like "rm 1187*" "rm 1188*" and so on.

also if the size of the mailbox usage remains high you might need to delete the maildirsize file, see this thread:

http://forums.cpanel.net/showthread.php?t=68409&highlight=maildirsize
 
Last edited:

prettydumb

Active Member
Aug 25, 2007
35
0
56
When you say "chunks"...

Is this a chunk? 1187* rm1197*

Would this mean I were deleting a "chunk" of ten files?

If so, would the correct linux command be /home/user/mail/cur/1187* rm1197*
 

nyjimbo

Well-Known Member
Jan 25, 2003
1,133
1
168
New York
When you say "chunks"...

Is this a chunk? 1187* rm1197*

Would this mean I were deleting a "chunk" of ten files?

If so, would the correct linux command be /home/user/mail/cur/1187* rm1197*
If you try to do a mass delete and there are too many it might say something about the file list being too big and it wont delete anything. Doing a "rm 1187*" might be deleting hundreds of files are they are LONG file names.

Go into the cur directory and do a :

ls|wc

which will list the files to a counter and print out a count (the leftmost number in the output is the count of files in the folder). If its small then you should just be able to delete them with the "rm *" but PLEASE be sure you are in the right folder or you could kill your machine.