Monday, June 6, 2022

[SOLVED] Finding files with same size (potential duplicates) in nested sub-folders in Linux Mint shell?

Issue

I have used rdfind, fdupes and fslint and have looked at previous posts such as href="https://stackoverflow.com/questions/7541616/how-to-find-files-with-same-size">this one. However the solution in the linked post does't help with files scattered in nested sub-folders. rdfind, fdupes and fslint work well, they removed a lot of duplicate files, but fail to find all of them. I still can see a lot of duplicate files that have exactly the same file size. Is there any way that I can find all files that have the same file size scattered in nested sub-directories of a folder?


Solution

#prefix each filepath with the size of the file padded to 10 places
find . -type f -printf "%10s\t%p\n" | 
sort --numeric | #sort numerically (uniq needs this) 
uniq --repeated --check-chars=10 #select duplicates 

See the respective manpages for more details.



Answered By - PSkocik
Answer Checked By - Senaida (WPSolving Volunteer)