A Digital Life

My Notebook

View My GitHub Profile

  • About
  • 7 July 2016

    mv: do not override destination file that is newer than source file (update move)

    by kerner1000

    mv does not support the update option, unlike rsync and cp. If your version of coreutils does support it, using cp (followed by rm) is the easiest way to perform an update move operation:

    $ cp -avu * [destination]
    $ rm -rf *
    

    Note that this will override only newer (by timestamp) files. It is not suitable for resuming a failed cp/ move. For this, you might use

    rsync -va --append dirA dirB
    
    

    instead. Note that dirA and dirB need to be present. See here for more details.

    tags: terminal