<div class="gmail_quote">On Sat, Apr 23, 2011 at 7:44 AM, Tom H <span dir="ltr"><<a href="mailto:tomh0665@gmail.com">tomh0665@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Sat, Apr 23, 2011 at 8:40 AM, Peng Yu <<a href="mailto:pengyu.ut@gmail.com">pengyu.ut@gmail.com</a>> wrote:<br>
><br>
> I'm looking for a fast way to get all the hard links that point to the<br>
> same file.<br>
><br>
> file="/blah/blah"<br>
> find $(stat -c %m "$file") -inum $(stat -c %i "$file")<br>
><br>
> Currently, I have a slow way. It traverses the mount point that the<br>
> file is on and look for all the files that have the same inum. But<br>
> traversing the whole file system is a slow operation. Does the linux<br>
> OS keep a table somewhere all the paths pointing to any file or the<br>
> linux OS only keep the number of the paths that point to a given inum<br>
> but does not keep the actual paths?<br>
<br>
</div>I've never seen "stat -c %m ..." before. I've just tried it and it<br>
doesn't work and isn't in the man pages of either Ubuntu or Fedora.<br>
I'd use df to get the mountpoint of a file.<br>
<br>
I've only ever used "find ... -inum ..." to find hard links but, for<br>
an extX filesystem, you can use dumpe2fs to get all the inode tables.<br>
That output probably holds the information that you're looking for,<br>
but I have no idea whether/how you can query it and get human-readable<br>
results from it.<br>
<div><div></div><div class="h5"><br>
--<br>
ubuntu-users mailing list<br>
<a href="mailto:ubuntu-users@lists.ubuntu.com">ubuntu-users@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-users" target="_blank">https://lists.ubuntu.com/mailman/listinfo/ubuntu-users</a><br>
</div></div></blockquote></div><br>You can get a pretty good start from<br>   find . -exec ls -di {} \; | sort -n<br clear="all">And (write a script to) look for adjacent entries with the same inode number.  Sorry, I'm<br>
too sleepy at the moment to write that, but perl or awk should be up to the task.<br><br>-- <br>Kevin O'Gorman, PhD<br><br>