I'm not well versed in shell scripting but I imagine this to be a painfully easy fix but its eluding me.
I need to copy the contents of a directory excluding a number of files. I have a command that works when I enter it into the terminal, but when its run in a shell script it fails with a syntax error or just doesn't work.
The command in question is:
cp -r path/to/!(dir1|dir2|dir3) destination
Any help would be greatly appreciated!