I'm trying to copy files from a directory while excluding a folder and a file. My problem is that a get an error with shopt extglob activated. Here is my code:
DEPLOY_SIMULATION_ENV="/home/user/Desktop/fancyproject/"
shopt -s extglob
cp -r ./!(nbproject|zexp.html) "$DEPLOY_SIMULATION_ENV"
shopt -u extglob
It gives me
‘/home/user/Desktop/myfancyproject/’ is not a directory
Of course, I want cp to create the directory myfancyproject atuomatically. I have a workaround with mkdir $DEPLOY_SIMULATION_ENV first but is there a way to do it with cp? It behaves strangely when extglob is active.