How to delete all except for some specific folder under parent-folder
You can use find
with a negation (at your own risk).
find all file and folders named "a" or "b":
find -name a -o -name b
find all files and folders name "a" or "b" in the current directory"
find -maxdepth 1 -name a -o -name b
find all files and folders not named "a" and not named "b" in current directory:
find -maxdepth 1 ! -name a ! -name b
also exclude current directory from result
find -maxdepth 1 ! -name a ! -name b ! -name .
now you can use rm
to delete all founded elements:
find -maxdepth 1 ! -name a ! -name b ! -name . -exec rm -rv {} \;