Topic: find and rm everything in a folder, except certain files
I came up with a nifty time saver, if you have a folder full of data, and you need to prune everything out except a couple of folder, then the following works pretty well:
find . \! -path "*folder_or_file_name*" -print0 | xargs -0 rm -rIf you need to save more than one folder or file, then adding extra tests like the following will work:
-path "*folder_or_file_name*"Let me know how it works for you, I have used it a few times, and it hasn't failed me yet. Would I use it on '/', probably not, but hey, it's a free command!