A
A
Anatoly2019-06-02 04:50:46
linux
Anatoly, 2019-06-02 04:50:46

How to delete empty folders other than the parent?

There is such a folder structure: /var/test/aaa/bbb/ccc
all folders including test do not contain files
How to delete all empty folders in the test folder, except for the test folder itself?
Command:
find /var/test/ -type d -empty -delete
deletes all folders, including the test folder itself

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2019-06-02
@Tolly

find
-mindepth 1 means process all files
except the starting-points

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question