So here's content under my /html
folder.
[root@ip-10-0-7-121 html]# ls
a wp-activate.php wp-content wp-mail.php
b wp-admin wp-cron.php wp-settings.php
healthy.html wp-blog-header.php wp-includes wp-signup.php
index.php wp-comments-post.php wp-links-opml.php wp-trackback.php
license.txt wp-config.php wp-load.php xmlrpc.php
readme.html wp-config-sample.php wp-login.php
I want to delete everything except for folder a
and b
without having to move a
/b
folder to another folder.
What's the command to do that?
Best Answer
You can use
find
with a negation (at your own risk).find all file and folders named "a" or "b":
find all files and folders name "a" or "b" in the current directory"
find all files and folders not named "a" and not named "b" in current directory:
also exclude current directory from result
now you can use
rm
to delete all founded elements: