Search code examples
linuxdeploymentconsolecopyingmc

Overwrite file in copying IF content to of them not the same


I have a lot of files from one side (A) and a lot of other files in other place (B)

I'm copying A to B, there are a lot of files are the same, but content could be different!

Usually I used mc (Midnight Commander) to do it, and selected "Overwrite if different size". But there is a situation when size are the same, but content is different. In this case mc keeps file in B place and not overwrite it.

In mc overwrite dialog there is a work "Update" I don't know what it is doing? In help there is no such information, maybe this is a solution?

So I'm searching solution which can help me copy all files from A to B and overwrite files in B place if they exists AND content is different from A.

if file in "B" place exists (the same name) and content is different it has to be overwritten by file from "A" place every time.

Do you know any solution?


Solution

  • Have you tried the command line:

    cp -ru A/* B/
    

    Should copy recursively all changed files (more recent timestamp) from directory A to directory B.

    You can also use -a instead of -r in the command line, depending on what you want to do. See the cp man page.