M
M
Maxim Makhnyuk2012-02-07 23:25:51
linux
Maxim Makhnyuk, 2012-02-07 23:25:51

How to delete a directory in Linux? :)?

There are a lot of files in a directory (on ext3).
1. rm -rf damn_dir (thinks for an hour, thinks for two, thinks for a day and won't be born)
2. ls damn_dir | wc -l (see point 1)
3. find damn_dir | xargs rm -f (thinks for an hour and, having filled in 16Gb of RAM, goes into swap and falls into the bark)
4. find damn_dir -type f | while read -r; do rm "$REPLY"; done (see point 3)
Any other options?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
X
xaker1, 2012-02-07
@xaker1

find . -delete
Finds and immediately deletes files.
As far as I remember, the other options first prepare the listing, and only then delete it.

H
himik, 2012-02-07
@himik

find damn_dir -name '*' -exec rm {} \;

P
prox, 2012-02-08
@prox

serverfault.com/questions/183821/rm-on-a-directory-with-millions-of-files ?

N
niko83, 2012-09-25
@niko83

similar problem and discussion habrahabr.ru/post/152193/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question