V
V
vlarkanov2018-09-19 14:32:42
linux
vlarkanov, 2018-09-19 14:32:42

BASH: how to delete a huge number of directories containing directories and files?

Actually, subject.
There is an abstract /data/maindir containing many subdirectories containing several more levels of subdirectories and small files at the lowest level.
How to clean up /data/maindir as quickly as possible (you don't need to delete this directory)?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Cheremisin, 2018-09-19
@leahch

It will not work quickly, alas ...
There are several options, the very first is to rename this directory and create a new one in its place with the same name and rights.
And already leisurely clean the renamed directory.
It is best, of course, to mount the partition at this point, and format it if necessary.

P
pfg21, 2018-09-19
@pfg21

rm -r /data/maindir/* ??

H
hx510b, 2018-09-21
@hx510b

find /pathto [ options ] -delete
deletes what is set and the fastest,
and without the -delete key, you can check that the list is the one you wanted.

V
Vovanys, 2018-09-19
@Vovanys

If the size is not large, but just a large number of files, then you can do tmpfs (in RAM), then it will be deleted faster.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question