BASH copy all files except one BASH copy all files except one bash bash

BASH copy all files except one


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


rsync has been my cp/scp replacement for a long time:

rsync -av from/ to/ --exclude=Default.png-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)-v, --verbose               increase verbosity


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/ {} +