You can use cp -u or –update options to copy only when the source file/directory is newer than the destination file/directory or when the destination file/directory is missing.
1 2 3 4 5 6 7 8 9 |
mkdir mydir{1,2} ## create some files and directories echo "one" > mydir1/myfile1 cp -v mydir1/myfile1 mydir2/ ## myfile1 will be copied from mydir1 to mydir2 cp -uv mydir1/myfile1 mydir2/ ## does nothing echo "two" > mydir1/myfile1 cp -uv mydir1/myfile1 mydir2/ ## myfile1 will be copied from mydir1 to mydir2 rm -r my* |