When copying files with
cp -H or
cp -L, I get the same results:
$ ls -l fileA fileA -> fileB $ cp fileA somewhere/ -H $ ls -l somewhere/ fileA # fileA is a copy of fileB, only renamed, with same properties!
This answer here describes both options as similar UNLESS used in combination with
-R. Not for me. Soft- as hardlinked files become renamed copies of the files they point to at the source.
What is the proper use of
cp -H and
cp -L? Is this the expected behavior?
My attempt to solve:
man cp tells me quite the same for both options, but
info cp's wording makes it even more confusing for me. Maybe one can help me break this down a bit:
-HIf a command line argument specifies a symbolic link, then copy the file it points to rather than the symbolic link itself. However, copy (preserving its nature) any symbolic link that is encountered via recursive traversal.
This sounds like a contradiction to me: I guess that »a symbolic link's nature« is that it points somewhere…
-L, --dereferenceFollow symbolic links when copying from them. With this option,
cpcannot create a symbolic link. For example, a symlink (to regular file) in the source tree will be copied to a regular file in the destination tree.
I do know that a symlink isn't a regular file, but… I admit I'm overchallenged with this explanation here.