Linux - How to find duplicate files
DD, I need to search for linux ubuntu in the home directory to find duplicate files, can you use a package or just a command? Thanks
Here's how to find duplicate files in the / home directory, including subdirectories:
Here's how to find duplicate files between two / home / user and / mnt / backup directories, including subdirectories:
With
As a result, it will ask you which file to keep (for example, 199 duplicates were found below):
Set 1 of 199, preserve files [1 - 2, all] (1848059712 bytes).
(1 = keep first, 2 = keep second, all = keep both)
The same thing that fdupes won't ask you if you want to delete the file:
Another option is the diff tool, comparing two files and deleting the duplicate:
If you prefer a graphical interface, use
Other alternatives are:
rdfind
fslint (GUI)
dupeGuru (GUI)
Then I needed some ultra fast search for (possible) duplicate files so that it wouldn't do sum (hash, md5 etc), which takes so much time. For this purpose I just wanted to look for duplicate files of the same size, which is now. I found this command and works flawlessly = returns only files that are the same size:
Or duplicate by same name:
REPLY
Here's how to find duplicate files in the / home directory, including subdirectories:
fdupes -r / home
Here's how to find duplicate files between two / home / user and / mnt / backup directories, including subdirectories:
fdupes -r / home / user / mnt / backup
With
d
you can delete duplicate files straight away, and S
will display the size: fdupes -rdS / home
As a result, it will ask you which file to keep (for example, 199 duplicates were found below):
Set 1 of 199, preserve files [1 - 2, all] (1848059712 bytes).
(1 = keep first, 2 = keep second, all = keep both)
The same thing that fdupes won't ask you if you want to delete the file:
fdupes -rdN / home
Another option is the diff tool, comparing two files and deleting the duplicate:
diff file1 file2 && rm file2
If you prefer a graphical interface, use
fslint
.Other alternatives are:
rdfind
fslint (GUI)
dupeGuru (GUI)
REPLY
Then I needed some ultra fast search for (possible) duplicate files so that it wouldn't do sum (hash, md5 etc), which takes so much time. For this purpose I just wanted to look for duplicate files of the same size, which is now. I found this command and works flawlessly = returns only files that are the same size:
find /cesta/adresar -type f -printf "%10s\t%p\n" | sort --numeric | uniq --repeated --check-chars=10
Or duplicate by same name:
find /path/dir -mindepth 1 -printf '%h %f\n' | sort -t ' ' -k 2,2 | uniq -f 1 --all-repeated=separate | tr ' ' '/'