find hard linked files (duplicate inodes) recursively

find . -type f -printf '%10i %p\n' | sort | uniq -w 11 -d -D | less
If you have two sets of files that may share hard-linked files, it can be useful to identify which ones are hard links to same underlying inode (file). This command shows you all of those, sorted by inode#. In my example the two directory trees to compare share a common parent, so I run the command in that parent and just use find . to start from the current directory. If yours are in different locations, you can pass both paths to find: find /directory1 /directory2 -type f -printf '%10i %p\n' | sort | uniq -w 11 -d -D | less
Sample Output
 190186228 ./10/alpha1/2612_fsm
 190186228 ./12/alpha1/base/19108/2612_fsm
 190203401 ./10/alpha1/pg_internal.init
 190203401 ./12/alpha1/base/19108/pg_internal.init
 190206322 ./10/alpha1/3079_fsm
 190206322 ./12/alpha1/base/19108/3079_fsm

By: dmmst19
2020-09-13 22:12:58

What Others Think

After submitting this I learned about fdupes -H which is sounds like will do pretty much the same thing.
dmmst19 · 1 week and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: