Skip to content

Instantly share code, notes, and snippets.

@mjf
Forked from anonymous/fdups
Last active July 26, 2019 10:54
Show Gist options
  • Save mjf/4327d98f714373ec6850 to your computer and use it in GitHub Desktop.
Save mjf/4327d98f714373ec6850 to your computer and use it in GitHub Desktop.
#! /bin/sh
# fdups - Finds duplicated files in given path
# Copyright (C) 2019 Matouš Jan Fialka, <http://mjf.cz/>
# Released under the terms of "The MIT License"
FDUPS_SUMPROG="${FDUPS_SUMPROG:-sha512sum}"
fdups1() {
find "$1" ! -type d -printf '%s\n' |
sort -n |
uniq -d |
xargs -I@@ -n1 find "${1:-.}" -type f ! -size 0 -a -size @@c -exec "$FDUPS_SUMPROG" {} \; |
sort -k1,32 |
uniq -w32 -d --all-repeated=separate |
sed 's/^[^ ]\+ \+//'
}
for path in ${@:-.}; do
fdups1 "$path"
printf -- '\n'
done 2>/dev/null
# vi:ft=sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment