This question already has an answer here:
I want to delete all files and directories from a specific directory except for one directory. For the same operation I had run this command
# rm -R -df !(dir_name_not_to_delete)
It works in Ubuntu but it gives an error in CentOS; i.e.,
-bash: !: event not found " what is the reason for this error"
What do I have to use in CentOS to get this to work? Is there any alternative of '!' this sign in Centos?