0

ls -lai on a file gives me a link count of 2:

16508 -rw-rw-rw- 2 ...

Then looking for all the filenames returns only one:

find "$dir" -inum 16508

This lists only the original file, not two. What's wrong?

Also, if I am deleting files with this code:

find "$dir" -type f -links +1 -exec rm '{}' \;

how do I ensure that I don't delete the last filename (given that the link count seems incorrect in the above example)?

1

The problem was simply that the other filename resided outside of $dir. Running:

find / -inum 16508

found both filenames.

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.