1

This is really weird. I am trying to copy a file. I do cp config.yaml config-test.yaml. However, I get cp: ‘config.yaml’ and ‘config-test.yaml’ are the same file.

ls -l config*.yaml gives

May 30 16:01 config-train.yaml Jun 1 14:09 config.yaml

config-test.yaml does not exist in the directory yet.

Never seen this before all this years using cp. Can any one tell me what's going on?

Thanks.

EDIT:

when I do ls -li config*.yaml I get:

398985520 -rw-r--r-- 1 y91 user 3088 May 30 16:01 config-train.yaml
398985526 -rw-r--r-- 1 y91 user 3091 Jun  1 14:09 config.yaml

Note, I can't see config-test.yaml. However, when I do ls -li config-test.yaml, I get:

398985526 -rw-r--r-- 1 y91 user 3091 Jun  1 14:09 config-test.yaml

Why couldn't I see config-test.yaml when I simply did ls -li config*.yaml? Why do I have to explicitly list it?

  • Can we get a long directory listing of those files e.g. ls -l config*.yaml – thrig Jun 2 '17 at 22:40
  • 3
    2 files with the same inode, one of them not visible when you enumerate the directory, but is visible when you explicitly try to stat() it. This smells like filesystem corruption. – Patrick Jun 2 '17 at 23:19
  • config-test.yaml probably has some non-graphic characters in it. Try ls -b – Mark Wagner Jun 2 '17 at 23:36
3

If you examine the output of ls -li for the two files you will probably notice that they are the same file (i.e. hard linked together). You see this if the two files have the SAME inode number in the ls listing. Thus, the reporting of the files being the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.