I would like to copy all files out of a dir except for one named Default.png. It seems that there are a number of ways to do this. What seems the most effective to you?
I'd just do:
cp srcdir/* destdir/ ; rm destdir/Default.png
unless the files are big. Otherwise use e.g.
find srcdir -type f/ |grep -v Default.png$ |xargs -ILIST cp LIST destdir/
# chattr +i /files_to_exclude
# cp source destination
# chattr -i /files_to_exclude
This works great for copying everything
except node modules
. enjoy and thanks to the answers above I have just added on to it. Rsync is better in my opinion than CP as you can see progress bar without asking for it.
rsync -av fromDirectory/ ToDirectory/ --exclude=node_modules
Should be as follows:
cp -r !(Default.png) /dest
If copying to a folder nested in the current folder (called example in the case below) you need to omit that directory also:
cp -r !(Default.png|example) /example
Simple, if src/
only contains files:
find src/ ! -name Default.png -exec cp -t dest/ {} +
If src/
has sub-directories, this omits them, but does copy files inside of them:
find src/ -type f ! -name Default.png -exec cp -t dest/ {} +
If src/
has sub-directories, this does not recurse into them:
find src/ -type f -maxdepth 1 ! -name Default.png -exec cp -t dest/ {} +
use the shell's expansion parameter with regex
cp /<path>/[^not_to_copy_file]* .
Everything will be copied except for the not_to_copy_file
-- if something is wrong with this. please Specify !