Solved

Find duplicate, hard linked files ?

Posted on 2007-11-26
6
452 Views
Last Modified: 2008-02-01
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
Comment
Question by:pillmill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 20354559
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
 
LVL 43

Expert Comment

by:ravenpl
ID: 20356393
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
 

Author Comment

by:pillmill
ID: 20362107
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 40

Expert Comment

by:omarfarid
ID: 20362486
Hi,

pillmill:

did you try the solution I gave?
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20363562
> 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
 
LVL 43

Accepted Solution

by:
ravenpl earned 500 total points
ID: 20363565
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question