Home > OS >  Cp when there is a hard link source file update existing target file leads to a hard link is created
Cp when there is a hard link source file update existing target file leads to a hard link is created

Time:10-31

At least coreutils 8.28 on ubuntu 18.04 LTS is such, try the following:

Has two folders, one is the source folder SRC, one is the target DST, a file folder under the SRC exist first, first create a hard link
$ln "SRC/first" "SRC/second"
And then copy all files into the DST SRC
=$cp - no - preserve the links "SRC/*" "DST/
"
Then the ls -l can see DST folder is two regular files,
Copy again, but use the -u to update
$cp - u - no - preserve=links "SRC/*" "DST/
"Use the ls -l to see both of DST folder becomes hard links, but DST/first and DST/second is a pair of, the SRC/SRC/second and first are a, use the find can be judged,

Added - no - preserve=the links are still unable to avoid this problem, and only - u will have this kind of problem, do not add - how many times u copy or regular files, even if no - no - preserve the copy for the first time is also a regular file, don't know what's going on for the second time becomes hard links, the

Excuse me, how should avoid this problem? Or, is there any other solutions? Once in the copy files to FAT32 partition ate this kind of loss, error no permissions directly, after just know is a hard link problems,

CodePudding user response:

Cp infopage - update parameters of such an interpretation, don't know what meaning, no translation to understand, but should be related to the (of course, I just want to solve, and not just to understand the problem)
Consequently, depending on the order that files are processed from the source, newer files in the destination may be replaced, to mirror hard links in the source.
  • Related