Question

I'm writing a script that needs to erase everything from a directory except two directories, mysql and temp.

I asked a question earlier and got this code that works in the command line:

rm -rf !(mysql|temp)

However it doesn't work in the script. I get this error "Syntax error: "(" unexpected".

Is there something special about parentheses I need to do?

Was it helpful?

Solution

You probably need to explicitly enable extended patterns in your script:

shopt -s extglob
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top