I have searched and searched for an answer to this question, and I have used some of the answers I found in the past for finding and deleting large numbers of directories that are named by a certain pattern, such as all directories named "example" including all of their contents recursively such as /directory1/example/files, /directory2/subdirectory/example/files, /directory3/../../subdirectory/example/more/more/files, where everything below the directory named "example" was deleted including the "example" directory itself. To accomplish that, I've used commands such as
find . -name example -type d -exec rm -rf {} +
THE EXCLAMATION POINT PROBLEM In this case however, I have a large number (maybe 300 or so) of directories that were uploaded to my server accidentally that need to be removed. The unwanted directories are all named "!originals". I need to remove all of the directories as well as all of their contents. My problem is in dealing with the exclamation point which is included in the names of all of these directories. For some reason, I am unable to escape the character when using a command such as the example given above. I have tried
find . -name *originals -type d -exec rm -rf {} +
find . -name !originals -type d -exec rm -rf {} +
find . -name \!originals -type d -exec rm -rf {} +
find . -name "\!originals" -type d -exec rm -rf {} +
find . -name '\!originals' -type d -exec rm -rf {} +
I really thought the last one in the list had potential. But on execution there was nothing happening. Just returning to the command prompt with no errors given and no files or directories affected.
If this has been answered somewhere else, I apologize. But I will be surprised, given the amount of searching I did regarding this issue. I have tried everything I can think of to find a solution, prior to posting here. So I hope this is a valid question, for which someone has a workable solution. Thank you in advance to all of you who provide help here.