Solved

Find duplicate, hard linked files ?

Posted on 2007-11-26
6
448 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
  • 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why VNC doesn't work in Redhat? 11 45
Virtualizing very old guest OS 4 80
nagios remote hosts 9 46
how to rebuild XFS volume from LV 19 40
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now