Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 461
  • Last Modified:

Find duplicate, hard linked files ?

How do I find all the duplicated, hard linked files in a UNIX/LINUX file system ?
I want to find all the files with the same INODE and the same Name,
but that are in different directories.
0
pillmill
Asked:
pillmill
  • 3
  • 2
1 Solution
 
omarfaridCommented:
Hi,

pillmill:

I think you have a posted similar question about finding files of same inode, and I am repeating the solution with a different find command.

The command ls -i will show the inode of a file. Also the find command with the -inum option will find files b inode number.

So if you know the inode number of a file you can use

find /dir -type f -inum number -name filename -mount

The number is the inode number of the file

the -mount option is to restrict search to the same filesystem since files on different filesystem can have the same inode number (hence are different files)

- type f is to list files only (directories will not have the same inode number)
0
 
ravenplCommented:
if You look for files that just have more than one link (it have another name), issue

find /dir -mount -type f -links +1 -printf "%i %p" | sort -n
the output is sorted by inode number
inode_number name
0
 
pillmillAuthor Commented:
find -links +1   seems to identify files with symbolic links.
I want to find all the files and all the Inodes for which the files
have hard links. This means that the Inodes are the same,
but the directory location is different. How do I get this
list from scanning all the files in the directory structure ?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
omarfaridCommented:
Hi,

pillmill:

did you try the solution I gave?
0
 
ravenplCommented:
> find -links +1   seems to identify files with symbolic links.
Untrue - just verified.
Mine does exaxtly what You want. just give some mountpoint as a /dir.
0
 
ravenplCommented:
But You may want to add \n to the printf
find /dir -mount -type f -links +1 -printf "%i %p\n" | sort -n
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now