Linux how to copy but not overwrite?

I want to cp a directory but I do not want to overwrite any existing files even it they are older than the copied files. And I want to do it completely noniteractive as this will be a part of a Crontab Bash script. Any ideas?


Taken from the man page:

-n, --no-clobber
              do not overwrite an existing file (overrides a previous -i option)

Example:

cp -n myoldfile.txt mycopiedfile.txt

Consider using rsync .

rsync -a -v src dst

But this will update files if differ.


As per comments

rsync -a -v --ignore-existing src dst

will ignore existing files completely.


cp -n

Is what you want. See the man page.

链接地址: http://www.djcxy.com/p/78116.html

上一篇: init没有显示我想要的printk

下一篇: Linux如何复制但不能覆盖?