Skip to content

Instantly share code, notes, and snippets.

@dima2306
Created April 1, 2024 09:29
Show Gist options
  • Select an option

  • Save dima2306/01a45a5a9617d8fae3b9c1741c3f6698 to your computer and use it in GitHub Desktop.

Select an option

Save dima2306/01a45a5a9617d8fae3b9c1741c3f6698 to your computer and use it in GitHub Desktop.
How to find duplicate files?
#
# look for files of size 512Kb or more (for movies can be set to something large)
# if file size differs, files are different
# if file size is same, compare their MD5 hashes
# if hashes match, output these files as duplicates
#
# Author: https://www.reddit.com/r/synology/comments/10yxgjq/comment/j80p942
#
find . -not -empty -links 1 -type f -size +512k -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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment