#/bin/bash #Script to detect hardlink in the file system from the current directory #Bertrand VANDEPORTAELE 2016 #inspired from http://superuser.com/questions/485919/how-can-i-find-all-hardlinked-files-on-a-filesystem #run this script from the folder where you want to detect the files #this script has to be run as sudo in order to recurse inside directory with restricted read access #find ./ -type f -printf '%n %p\n' | awk '$1 > 1{$1="";print}' #to display the inode number and the number of hardlinks for each inode #find ./ -type f -links +1 -printf '%i %n %p\n' #to sort by inode number and thus regroup harlinks to similar inode find ./ -type f -links +1 -printf '%i %n %p\n' | sort -n -k 1