Recently I have bought an USB hard-disk which is 2TB for $90 from US. And I have copied some English 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/ [1] /media/Movies/ENGLISH MOVIES/The Pursuit of Happyness.avi [2] /media/Movies/ENGLISH MOVIES/The.pursuit.of.happyness.(2006)/The Pursuit of Happyness.avi Set 1 of 13, preserve files [1 - 2, all] (735221760 bytes each): 1 [+] /media/Movies/ENGLISH MOVIES/The Pursuit of Happyness.avi [-] /media/Movies/ENGLISH MOVIES/The.pursuit.of.happyness.(2006)/The Pursuit of Happyness.avi
if you see i just deleted first files(+) and which is not deleted is shown in above output. Enjoy with the command and give us feedback at http://forums.linuxnix.com
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018