I can run this command from my command line prompt:
cp -r folder/!(exclude-me) ./
To recursively copy all contents of
folder except for the subdirectory named
exclude-me into the current directory. This works exactly as intended. However, I need this to work in a bash script I've written, where I have this:
if [ -d "folder" ]; then cp -r folder/!(exclude-me) ./ rm -rf folder fi
But when I run the script:
I get this:
my-script.sh: line 30: syntax error near unexpected token `(' my-script.sh: line 30: ` cp -r folder/!(exclude-me) ./'
And I'm at a loss as to why it works from the command prompt, but the exact same line doesn't work in a bash script.