shell - Copy all files in directory except ".txt" and not to replace existing files -


i have copy file source directory destination directory , skip file extension ".txt" , not replace file if present in destination directory

example

source directory

    /a/aone.js     /a/atwo.js     /b/bone.txt     /b/btwo.js   

destination directory

    /a/atwo.js 

then should copy

    /a/aone.js     /b/btwo.js 

and skip "/a/atwo.js" because present in destination folder , skip "/b/bone.txt" because extension ".txt"

i tried command not work

 find /path/to/source/ \( ! -name "*.txt" \) -type f | cp -n /path/to/destination/ -r   cp -n /path/to/source/*(!*.txt) /path/to/destination/ -r 

assuming can use rsync, (vaz verbose, archive , compress - believe other options self explanatory)

rsync -vaz --exclude "*.txt" /path/to/source/ /path/to/destination/ 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -