When I use rm -r secrets/!(snapsearch) on the command line. It works and deletes everything in the secrets folder except for snapsearch folder.
However when I use the exact same command in a bash script and execute it, it complains about the parentheses.

syntax error near unexpected token `('Why does it work from the command line, and not from the bash script? And how can I make this work from the bash script?

Check Solution