Saturday, June 4, 2011

How to : Find simple OR duplicate files in Linux / Unix

Recently I have bought an USB hard-disk which is 1TB . And I have copied some movies around 500GB from one of my friends Hard disk. Then when I am checking the content I found that some of the movies are repeated and that to with different names, in different folders etc. This made finding them difficult. So how to find all those files and deleted them if not required. There is one command in Linux called fdupes(File DUPlicatES) which is not installed by default. Lets see how we can use it.

In Redhat/Fedora/CentOS

#yum install fdupes 

In Debain/Ubuntu

#apt-get install fdupes

Once installed you can use right away to find duplicates..

To find duplicates in a folder

#fdupes /path/to/folder

This will find all the duplicate files in that folder. What about if you want to find in sub folders too?

Use -r option to recursive search..

#fdupes -r /path/to/folder

but this will not show what is the size of that duped files? Then there is any option to find sizes too? Yes you can use -S to find sizes too..

#fdupes -S -r /path/to/folder

What about deleting them with a conformation so that you no need to go into every folder and delete them.

#fdupes -d -r /path/to/folder

Sample output

#fdupes -d -S -r /media/Movies/

0 comments:

Post a Comment