Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 03-31-2003, 11:17 PM   #1
Registered: Feb 2003
Location: Phoenix, AZ - USA
Distribution: RedHat 8, Micro$haft
Posts: 33

Rep: Reputation: 15
Deletion of massive number of files

I'm running a process that will dump over 1 million images into a directory.

My test platform currently has about 500,000 images in a single dir. I am running HedHat 8 with ReiserFS on that directory.

How do I delete them??

"rm * -f" times out stating the collection is too large.

I have found the fastest method so far is to loop a php script with the "unlink" function deleting one image at a time. But this will still take several hours to delete 500,000 files.

Is there some utility or something I can tell to just drop the entire directory - quickly - like just a few seconds?


Old 04-01-2003, 12:19 AM   #2
Registered: Dec 2002
Location: St. Louis, MO
Distribution: Slackware 9.1
Posts: 482

Rep: Reputation: 30
You can delete a dir with contents with rm -rf. I don't understand why you'd delete the images one by one instead of just the dir and all files within it.

EDIT: I apologize for misreading it.

Last edited by snocked; 04-01-2003 at 12:22 AM.
Old 04-01-2003, 01:12 AM   #3
LQ Newbie
Registered: Jan 2003
Location: Texas
Distribution: Linux
Posts: 2

Rep: Reputation: 0
you can get rm to work fine for your issue. Just make sure you delete the directory the images reside instead of the images within it.


cd up to the level above of the images, not in the directory itself and run:

rm -fr images/

Old 04-01-2003, 09:29 AM   #4
Registered: Dec 2001
Location: Stockholm, Sweden
Distribution: Ubuntu, Kubuntu and Debian
Posts: 338

Rep: Reputation: 30
Otherwise you might do:
rm -f A*
rm -f B*
rm -f C*
rm -f a*
rm -f b*
rm -f c*

...another simple solution which would probably work...
Old 04-01-2003, 02:27 PM   #5
LQ Newbie
Registered: Jul 2002
Location: Stockholm, Sweden
Distribution: Debian
Posts: 16

Rep: Reputation: 2
find . | xargs rm -f

The xargs command will divide the files in appropriate chunks. You can modify the options to find if you don't want all files to be deleted.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Number of files in directory bullium Linux - General 13 08-31-2011 09:50 AM
help recovering from chkdsk.exe deletion of files? Lleb_KCir General 11 07-15-2005 01:30 PM
Number of Open Files rjapenga Linux - General 2 04-14-2005 02:01 AM
Accidental Deletion of some /usr/lib files Huddlebum Linux - General 17 03-08-2004 03:05 PM
Foolish deletion of /etc/fonts/ files & Gimp diversityx Linux - General 0 01-28-2003 04:45 PM > Forums > Linux Forums > Linux - General

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