deleting millions of files at once
I have this folder with probably over 1 million small files, suprised it did not crash the filesystem due to the inode limit, but anyway, when I do a rm to delete them all, it errors out with -bash: /bin/rm: Argument list too long. Is there a quick way (other then formatting) to delete all these?
|
Assuming you want the folder and all its files gone:
rm -rf /path/to/folder The reason you get argument list to long is that the shell expands wildcards like *. You can delete a few files at a time with rm [a-c]* for all file beginning with a, b, or c, which may put you under the limit. As always, with rm and wildcards, be very very careful. Linux does not have an undelete. |
go to the folder, do:
for i in `ls`; do rm $i; done but ONLY do it in the folder!! |
Thanks that for loop one worked. Never thought of doing that. Well would not have known how anyway. :P
Speaking of not being an undelete in linux, is there any utility you can get to restore files? or does deleting in linux actually destroy the file, unlike windows? Would be handy to have in case I ever goof up or something. |
Last time I deleted something I should not (stupid console emulator from Konqueror!!!!) I found that in ext2 filesystems files can be restored, but in ext3 isn't possible because......well, bacause something i don't remember :p
|
Quote:
|
Quote:
|
All times are GMT -5. The time now is 05:42 AM. |