Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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