[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to find all hard links of the same file



linuksos wrote:
Hi,

or you can try to search for all files which have more than one link:

find </your/path/to/search/> -type f -links +1 -ls



Since the actual location of the file is unknown and the find command gets names from directories in the order found (not sorted in any way), I'd suggest running a pipe to a numeric sort:

  find .... -ls | sort -n -k1

Then, your common inode value (the samefile) will be together. Another option, if you're working on a system that has a more primitive version of 'find' (no -xdev, -samefile options, for example) would be to use:

  ls -i file

which outputs the file's inode, then do a:

  find <root_of_filesystem> -inum inode_number

Note that the <root_of_filesystem> is the mount point for the device where the file exists. You can get this quickly by using:

  df .

in the directory where the file of interest exists.

--
Bob McGowan

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


Reply to: