You may perhaps copy everything recursively and then delete similary what you did not want:
cp -r srcPath destPath
rm -r `find destPath -name '.abc'`
But to avoid copying and then deleting (for example if ".abc" are large files), I don't know if there are easier solutions, but I would make a shell script. A once-usable version (which could be improved by handling parameters) would look like this:
Code:
#!/bin/sh
# use find to list all files from the source location
# and grep -v to remove those called ".abc"
# and store the list into a variable:
flist=`find mySrc/path/ | grep -v '\<\.abc\>'`
# foreach item we want to copy:
for fname in $flist; do
# we compute the corresponding destination path:
destname=`echo " "$fname | sed 's/ mySrc\/path\// dest\/location\//'`
if [ -d $flist ] ; then
# if the item is a directory, we create it:
mkdir $destname
else
# if not a directory, we copy it:
cp $fname $dest
fi
done
I put in blue what you may want to change (or use parameters instead of). Don't forget to escape with a backslash every slash and dot in the grep and sed commands as I did.
The "\<" and "\>" around "\.abc" just means that the name of the file or directories to skip is ".abc" and not just any name containing ".abc" somewhere inside.
Once your script done, you can launch it in the usual ways: either use
sh myScriptName or make your script executable
chmod u+x myScriptName (only once) and then launch it with
./myScriptName provided you are in its directory.
Also remember that if you use relative paths in the blue zones of the script, they will be relative to the path you are launching your script from.