Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)?

share|improve this question
up vote 1 down vote accepted

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

find / -inum 16508

found both filenames.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .