commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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:
This dup finder saves time by comparing size first, then md5sum, it doesn't delete anything, just lists them.
There are 9 alternatives - vote for the best!
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.
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.
Improvement of the command "Find Duplicate Files (based on size first, then MD5 hash)" when searching for duplicate files in a directory containing a subversion working copy. This way the (multiple dupicates) in the meta-information directories are ignored.
Can easily be adopted for other VCS as well. For CVS i.e. change ".svn" into ".csv":
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
Avoids the nested 'find' commands but doesn't seem to run any faster than syssyphus's solution.
A bit shorter and parallelized. Depending on the speed of your cpu and your disk this may run faster.
Parallel is from https://savannah.nongnu.org/projects/parallel/
If you can do better, submit your command here.
You must be signed in to comment.
As an alternative, check out http://www.pixelbeat.org/fslint/ in case you don't mind using a GUI for this. It gives you the option of hard linking the duplicate files and doing other lint-y tasks. Available as package 'fslint' at least in debian/ubuntu.
Thanks for the FSlint reference. Note fslint uses much the same mechanism underneath and has a CLI mode.
http://fslint.googlecode.com/svn/trunk/fslint/findup
awsome, much faster then fdupes.
Isn't the -D redundant?
yes it is... thanks for noticing, I fixed it.
How can you mass delete these files once they're found? (I'd like to keep one of them)
you might want to look at fdupes or fslint in order to help with hardlinking / deleting, etc... my command is really just a quick hack to list them.
There is also perfect match:
http://pmatch.rubyforge.org/
That's especially if you are commandline fan.
Fantastic, man. this is truly great.
There is also rmlint:
https://github.com/sahib/rmlint
Example:
rmlint [path] -GYX -v5
+ Gives you similiar results
+ you can pipe it directly to 'sh'
+ it's lots faster as additionally fingerprints are done and a few other tricks.
+ it has also other options ;-)
"find -type" doesn?t work on Mac OS X.
can filename comparison be added as a first step to the first solution given?
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
seems to me checking filename first could speed things up. if two files lack the same filename then in many cases i would not consider them a dupe.
thanks
The code for findup by Pádraig Brady (http://fslint.googlecodesh.com/svn/trunk/fslint/findup) is very OS (or user defined system) sensitive and is without comments that tell you what it is pointing to:
---------
./FindDups: line 62: /Programming/FSlint/supprt/fslver: No such file or directory
./FindDups: line 135: shell_quote: command not found
./FindDups: line 147: /Programming/FSlint/supprt/getfpf: No such file or directory
./FindDups: line 149: check_uniq: command not found
./FindDups: line 164: /Programming/FSlint/supprt/rmlint/merge_hardlinks: No such file or directory
---------
/Programming is my partition for assorted programming I am doing. I use openSUSE 12.1. I would assume (with all that connotes) that uniq could be used rather than check_uniq, and that the . /supprt directory is unique to another distro (why is there so much illogical difference - that eliminates a lot of people who would like to switch from Windows). Either that or it is one of Pádraig Brady's personnal directories and that does not fly unless they are included.
Considering this came from Google code, you have to first assume it is incomplete. And this is no exception to that!
Hi, I would like if it is any way of find duplicates of a given file (not all duplicates on the fs) maybe searching directly by md5.
It would be great for me.