How can I recursively copy a directory into another and replace only the files that have not changed?

前端 未结 3 663
迷失自我
迷失自我 2021-02-02 12:00

I am looking to do a specific copy in Fedora.

I have two folders:

  • \'webroot\': holding ALL web files/images etc

  • \'export\': folder cont

3条回答
  •  伪装坚强ぢ
    2021-02-02 12:35

    Sounds like a job for cpio (and hence, probably, GNU tar can do it too):

    cd export
    find . -print | cpio -pvdm /path/to/webroot
    

    If you need owners preserved, you have to do it as root, of course. The -p option is 'pass mode', meaning copy between locations; -v is verbose (but not interactive; there's a difference); -d means create directories as necessary; -m means preserve modification time. By default, without the -u option, cpio won't overwrite files in the target area that are newer than the one from the source area.

提交回复
热议问题