Recursively delete empty directories with a dotfile / directory exclusion?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
How do I recursively delete all directories which do not contain any files and make an exclusion of hidden directories?
A lot of the directories that I wish to delete contain hidden directories (dot directories) with files inside them, I do not want these directories.
However, any directories with actually visible files in them - I wish to keep.
Any suggestions?
Example (I wish to delete)
v@localhost:~/test$ ls -al
total 20
drwxrwxr-x 3 v v 4096 Oct 28 04:31 .
drwxr-xr-x 255 v v 12288 Oct 28 04:38 ..
drwxrwxr-x 4 v v 4096 Oct 28 04:31 .hidden
Example (I wish to keep)
v@localhost:~/google.com$ ls -al
total 348
drwxrwxr-x 6 v v 4096 Oct 28 04:39 .
drwxr-xr-x 255 v v 12288 Oct 28 04:38 ..
-rw-rw-r-- 1 v v 54 Oct 28 04:39 BCF9360BE20A13B7DA407BF12AF28650.txt
-rw-rw-r-- 1 v v 254 Oct 28 04:39 crossdomain.xml
-rw-rw-r-- 1 v v 1150 Oct 28 04:39 favicon.ico
-rw-rw-r-- 1 v v 234 Oct 28 04:39 .htaccess
-rw-rw-r-- 1 v v 23 Oct 28 04:39 index.html
-rw-rw-r-- 1 v v 418 Oct 28 04:39 index.php
-rw-rw-r-- 1 v v 19935 Oct 28 04:39 license.txt
-rw-rw-r-- 1 v v 110249 Oct 28 04:39 php_errors.log
-rw-rw-r-- 1 v v 7344 Oct 28 04:39 readme.html
-rw-rw-r-- 1 v v 5456 Oct 28 04:39 wp-activate.php
drwxrwxr-x 9 v v 4096 Oct 28 04:39 wp-admin
-rw-rw-r-- 1 v v 364 Oct 28 04:39 wp-blog-header.php
-rw-rw-r-- 1 v v 1477 Oct 28 04:39 wp-comments-post.php
-rw-rw-r-- 1 v v 3376 Oct 28 04:39 wp-config-local.php
-rw-rw-r-- 1 v v 5219 Oct 28 04:39 wp-config.php
-rw-rw-r-- 1 v v 2853 Oct 28 04:39 wp-config-sample.php
drwxrwxr-x 7 v v 4096 Oct 28 04:39 wp-content
-rw-rw-r-- 1 v v 3286 Oct 28 04:39 wp-cron.php
drwxrwxr-x 17 v v 12288 Oct 28 04:39 wp-includes
-rw-rw-r-- 1 v v 2382 Oct 28 04:39 wp-links-opml.php
-rw-rw-r-- 1 v v 3353 Oct 28 04:39 wp-load.php
-rw-rw-r-- 1 v v 34057 Oct 28 04:39 wp-login.php
-rw-rw-r-- 1 v v 7993 Oct 28 04:39 wp-mail.php
-rw-rw-r-- 1 v v 13920 Oct 28 04:39 wp-settings.php
-rw-rw-r-- 1 v v 29890 Oct 28 04:39 wp-signup.php
-rw-rw-r-- 1 v v 4035 Oct 28 04:39 wp-trackback.php
-rw-rw-r-- 1 v v 3064 Oct 28 04:39 xmlrpc.php
linux find
New contributor
add a comment |Â
up vote
0
down vote
favorite
How do I recursively delete all directories which do not contain any files and make an exclusion of hidden directories?
A lot of the directories that I wish to delete contain hidden directories (dot directories) with files inside them, I do not want these directories.
However, any directories with actually visible files in them - I wish to keep.
Any suggestions?
Example (I wish to delete)
v@localhost:~/test$ ls -al
total 20
drwxrwxr-x 3 v v 4096 Oct 28 04:31 .
drwxr-xr-x 255 v v 12288 Oct 28 04:38 ..
drwxrwxr-x 4 v v 4096 Oct 28 04:31 .hidden
Example (I wish to keep)
v@localhost:~/google.com$ ls -al
total 348
drwxrwxr-x 6 v v 4096 Oct 28 04:39 .
drwxr-xr-x 255 v v 12288 Oct 28 04:38 ..
-rw-rw-r-- 1 v v 54 Oct 28 04:39 BCF9360BE20A13B7DA407BF12AF28650.txt
-rw-rw-r-- 1 v v 254 Oct 28 04:39 crossdomain.xml
-rw-rw-r-- 1 v v 1150 Oct 28 04:39 favicon.ico
-rw-rw-r-- 1 v v 234 Oct 28 04:39 .htaccess
-rw-rw-r-- 1 v v 23 Oct 28 04:39 index.html
-rw-rw-r-- 1 v v 418 Oct 28 04:39 index.php
-rw-rw-r-- 1 v v 19935 Oct 28 04:39 license.txt
-rw-rw-r-- 1 v v 110249 Oct 28 04:39 php_errors.log
-rw-rw-r-- 1 v v 7344 Oct 28 04:39 readme.html
-rw-rw-r-- 1 v v 5456 Oct 28 04:39 wp-activate.php
drwxrwxr-x 9 v v 4096 Oct 28 04:39 wp-admin
-rw-rw-r-- 1 v v 364 Oct 28 04:39 wp-blog-header.php
-rw-rw-r-- 1 v v 1477 Oct 28 04:39 wp-comments-post.php
-rw-rw-r-- 1 v v 3376 Oct 28 04:39 wp-config-local.php
-rw-rw-r-- 1 v v 5219 Oct 28 04:39 wp-config.php
-rw-rw-r-- 1 v v 2853 Oct 28 04:39 wp-config-sample.php
drwxrwxr-x 7 v v 4096 Oct 28 04:39 wp-content
-rw-rw-r-- 1 v v 3286 Oct 28 04:39 wp-cron.php
drwxrwxr-x 17 v v 12288 Oct 28 04:39 wp-includes
-rw-rw-r-- 1 v v 2382 Oct 28 04:39 wp-links-opml.php
-rw-rw-r-- 1 v v 3353 Oct 28 04:39 wp-load.php
-rw-rw-r-- 1 v v 34057 Oct 28 04:39 wp-login.php
-rw-rw-r-- 1 v v 7993 Oct 28 04:39 wp-mail.php
-rw-rw-r-- 1 v v 13920 Oct 28 04:39 wp-settings.php
-rw-rw-r-- 1 v v 29890 Oct 28 04:39 wp-signup.php
-rw-rw-r-- 1 v v 4035 Oct 28 04:39 wp-trackback.php
-rw-rw-r-- 1 v v 3064 Oct 28 04:39 xmlrpc.php
linux find
New contributor
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
How do I recursively delete all directories which do not contain any files and make an exclusion of hidden directories?
A lot of the directories that I wish to delete contain hidden directories (dot directories) with files inside them, I do not want these directories.
However, any directories with actually visible files in them - I wish to keep.
Any suggestions?
Example (I wish to delete)
v@localhost:~/test$ ls -al
total 20
drwxrwxr-x 3 v v 4096 Oct 28 04:31 .
drwxr-xr-x 255 v v 12288 Oct 28 04:38 ..
drwxrwxr-x 4 v v 4096 Oct 28 04:31 .hidden
Example (I wish to keep)
v@localhost:~/google.com$ ls -al
total 348
drwxrwxr-x 6 v v 4096 Oct 28 04:39 .
drwxr-xr-x 255 v v 12288 Oct 28 04:38 ..
-rw-rw-r-- 1 v v 54 Oct 28 04:39 BCF9360BE20A13B7DA407BF12AF28650.txt
-rw-rw-r-- 1 v v 254 Oct 28 04:39 crossdomain.xml
-rw-rw-r-- 1 v v 1150 Oct 28 04:39 favicon.ico
-rw-rw-r-- 1 v v 234 Oct 28 04:39 .htaccess
-rw-rw-r-- 1 v v 23 Oct 28 04:39 index.html
-rw-rw-r-- 1 v v 418 Oct 28 04:39 index.php
-rw-rw-r-- 1 v v 19935 Oct 28 04:39 license.txt
-rw-rw-r-- 1 v v 110249 Oct 28 04:39 php_errors.log
-rw-rw-r-- 1 v v 7344 Oct 28 04:39 readme.html
-rw-rw-r-- 1 v v 5456 Oct 28 04:39 wp-activate.php
drwxrwxr-x 9 v v 4096 Oct 28 04:39 wp-admin
-rw-rw-r-- 1 v v 364 Oct 28 04:39 wp-blog-header.php
-rw-rw-r-- 1 v v 1477 Oct 28 04:39 wp-comments-post.php
-rw-rw-r-- 1 v v 3376 Oct 28 04:39 wp-config-local.php
-rw-rw-r-- 1 v v 5219 Oct 28 04:39 wp-config.php
-rw-rw-r-- 1 v v 2853 Oct 28 04:39 wp-config-sample.php
drwxrwxr-x 7 v v 4096 Oct 28 04:39 wp-content
-rw-rw-r-- 1 v v 3286 Oct 28 04:39 wp-cron.php
drwxrwxr-x 17 v v 12288 Oct 28 04:39 wp-includes
-rw-rw-r-- 1 v v 2382 Oct 28 04:39 wp-links-opml.php
-rw-rw-r-- 1 v v 3353 Oct 28 04:39 wp-load.php
-rw-rw-r-- 1 v v 34057 Oct 28 04:39 wp-login.php
-rw-rw-r-- 1 v v 7993 Oct 28 04:39 wp-mail.php
-rw-rw-r-- 1 v v 13920 Oct 28 04:39 wp-settings.php
-rw-rw-r-- 1 v v 29890 Oct 28 04:39 wp-signup.php
-rw-rw-r-- 1 v v 4035 Oct 28 04:39 wp-trackback.php
-rw-rw-r-- 1 v v 3064 Oct 28 04:39 xmlrpc.php
linux find
New contributor
How do I recursively delete all directories which do not contain any files and make an exclusion of hidden directories?
A lot of the directories that I wish to delete contain hidden directories (dot directories) with files inside them, I do not want these directories.
However, any directories with actually visible files in them - I wish to keep.
Any suggestions?
Example (I wish to delete)
v@localhost:~/test$ ls -al
total 20
drwxrwxr-x 3 v v 4096 Oct 28 04:31 .
drwxr-xr-x 255 v v 12288 Oct 28 04:38 ..
drwxrwxr-x 4 v v 4096 Oct 28 04:31 .hidden
Example (I wish to keep)
v@localhost:~/google.com$ ls -al
total 348
drwxrwxr-x 6 v v 4096 Oct 28 04:39 .
drwxr-xr-x 255 v v 12288 Oct 28 04:38 ..
-rw-rw-r-- 1 v v 54 Oct 28 04:39 BCF9360BE20A13B7DA407BF12AF28650.txt
-rw-rw-r-- 1 v v 254 Oct 28 04:39 crossdomain.xml
-rw-rw-r-- 1 v v 1150 Oct 28 04:39 favicon.ico
-rw-rw-r-- 1 v v 234 Oct 28 04:39 .htaccess
-rw-rw-r-- 1 v v 23 Oct 28 04:39 index.html
-rw-rw-r-- 1 v v 418 Oct 28 04:39 index.php
-rw-rw-r-- 1 v v 19935 Oct 28 04:39 license.txt
-rw-rw-r-- 1 v v 110249 Oct 28 04:39 php_errors.log
-rw-rw-r-- 1 v v 7344 Oct 28 04:39 readme.html
-rw-rw-r-- 1 v v 5456 Oct 28 04:39 wp-activate.php
drwxrwxr-x 9 v v 4096 Oct 28 04:39 wp-admin
-rw-rw-r-- 1 v v 364 Oct 28 04:39 wp-blog-header.php
-rw-rw-r-- 1 v v 1477 Oct 28 04:39 wp-comments-post.php
-rw-rw-r-- 1 v v 3376 Oct 28 04:39 wp-config-local.php
-rw-rw-r-- 1 v v 5219 Oct 28 04:39 wp-config.php
-rw-rw-r-- 1 v v 2853 Oct 28 04:39 wp-config-sample.php
drwxrwxr-x 7 v v 4096 Oct 28 04:39 wp-content
-rw-rw-r-- 1 v v 3286 Oct 28 04:39 wp-cron.php
drwxrwxr-x 17 v v 12288 Oct 28 04:39 wp-includes
-rw-rw-r-- 1 v v 2382 Oct 28 04:39 wp-links-opml.php
-rw-rw-r-- 1 v v 3353 Oct 28 04:39 wp-load.php
-rw-rw-r-- 1 v v 34057 Oct 28 04:39 wp-login.php
-rw-rw-r-- 1 v v 7993 Oct 28 04:39 wp-mail.php
-rw-rw-r-- 1 v v 13920 Oct 28 04:39 wp-settings.php
-rw-rw-r-- 1 v v 29890 Oct 28 04:39 wp-signup.php
-rw-rw-r-- 1 v v 4035 Oct 28 04:39 wp-trackback.php
-rw-rw-r-- 1 v v 3064 Oct 28 04:39 xmlrpc.php
linux find
linux find
New contributor
New contributor
New contributor
asked 4 mins ago
vazovop
1
1
New contributor
New contributor
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
vazovop is a new contributor. Be nice, and check out our Code of Conduct.
vazovop is a new contributor. Be nice, and check out our Code of Conduct.
vazovop is a new contributor. Be nice, and check out our Code of Conduct.
vazovop is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478201%2frecursively-delete-empty-directories-with-a-dotfile-directory-exclusion%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password