find -type d -name ".csv" -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type d -name ".csv" -prune -o -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate
[...] f2e6bb247f110dcab63b4d38ff7b2dee ./themes/darkblue_orange/img/b_relations.png f2e6bb247f110dcab63b4d38ff7b2dee ./themes/original/img/b_relations.png f5309bd2a2fc5e512a0cc38ac6f10c09 ./themes/darkblue_orange/img/b_deltbl.png f5309bd2a2fc5e512a0cc38ac6f10c09 ./themes/original/img/b_deltbl.png f60bfbb7ce218a55650c1abbbbee06ae ./themes/darkblue_orange/img/s_lang.png f60bfbb7ce218a55650c1abbbbee06ae ./themes/original/img/s_lang.png f63a5ad833147eeb94adb4496ddbec41 ./themes/darkblue_orange/img/s_theme.png f63a5ad833147eeb94adb4496ddbec41 ./themes/original/img/s_theme.png f6ae61146ce3de8fa11b9e84e086bd04 ./themes/darkblue_orange/img/bd_drop.png f6ae61146ce3de8fa11b9e84e086bd04 ./themes/original/img/bd_drop.png f95d66c11bfed9198d13a278269c32b2 ./themes/darkblue_orange/img/s_loggoff.png f95d66c11bfed9198d13a278269c32b2 ./themes/original/img/s_loggoff.png [...]
This dup finder saves time by comparing size first, then md5sum, it doesn't delete anything, just lists them.
If you have the fdupes command, you'll save a lot of typing. It can do recursive searches (-r,-R) and it allows you to interactively select which of the duplicate files found you wish to keep or delete.
Calculates md5 sum of files. sort (required for uniq to work). uniq based on only the hash. use cut ro remove the hash from the result.
This works on Mac OS X using the `md5` command instead of `md5sum`, which works similarly, but has a different output format. Note that this only prints the name of the duplicates, not the original file. This is handy because you can add `| xargs rm` to the end of the command to delete all the duplicates while leaving the original.
Finds duplicates based on MD5 sum. Compares only files with the same size. Performance improvements on:
find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate
The new version takes around 3 seconds where the old version took around 17 minutes. The bottle neck in the old command was the second find. It searches for the files with the specified file size. The new version keeps the file path and size from the beginning.
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: