I often need to remove files or folders in a dierctory – but I also often must not delete the whole directory, so here is the shell syntax for removing everything from a directory excepting your searchparameter.
This removes all files and subfolders in your current folder, excepting the cgi-bin directory.
ls | grep -v cgi-bin | xargs rm -R