1

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 -r

If 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!

Faith without works is dead, faith without hearing is deaf. Salvation is dead without Faith and Works. But Salvation is not dependant on Works. You can always have Salvation, you just have to accept the gift that was given in love, from God himself, Jesus Christ. -- Aaron Echols