This works from the command line:
cp -r some/dir/!(.git) some/other/dir/
What I'm trying to accomplish is doing a recursive copy but ignore the .git sub-directory.
I want to put this in a shell script but the parentheses are causing me problems.
Placing that command in a shell script (bash) it gives me a syntax error.
If I escape the parentheses (with back-slashes), then I get the following error:
/usr/bin/cp: cannot stat 'some/dir/!(.git)': No such file or directory
How should the command be formed inside a bash shell script?
UPDATED 15-apr-2020:
Here is the code from my simplified shell script
#!/bin/bash
shopt -s extglob
TEST_DIR=./copy-to-here/
DIRS="
some-dir/
"
for dir in $DIRS; do
echo "${dir}!(.git}"
# /usr/bin/cp -rp "$dir!(.git)" $copytodir
ls -l "${dir}!(.git)"
done