You can use find with the -not operator:
find . -not -iname "*good*" -a -not -name "." -exec rm {} \;
I used -exec to call rm there, but I wonder if find built-in delete action , see below.
But be very careful with that. Please note that in the above I had to put the sentence -a -not -name "." because otherwise he matched . , current directory. Therefore, I thoroughly tested -print before inserting the -exec rm {} \; bit -exec rm {} \; !
Update : Yes, I never used it, but there really is a -delete action. So:
find . -not -iname "*good*" -a -not -name "." -delete
Again, be careful and double-check that you do not match more than you want at first.
Tj crowder
source share