2023-01-31 17:13:32 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Check the first file against all other ones given and print duplicates.
|
|
|
|
# Checks first size then diff.
|
|
|
|
# TODO diff initial bytes
|
2023-05-09 12:02:32 +00:00
|
|
|
if test $# -lt 2
|
|
|
|
then echo "Need at least 2 files to compare!" >&2
|
2023-01-31 17:13:32 +00:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
target="$1"
|
|
|
|
shift
|
|
|
|
for existing
|
|
|
|
do test "$(realpath "$target")" != "$(realpath "$existing")" -a -f "$existing" &&
|
|
|
|
test "$(stat --format %s "$target")" -eq "$(stat --format %s "$existing")" &&
|
|
|
|
diff -q "$target" "$existing" >/dev/null &&
|
|
|
|
echo "$existing"
|
|
|
|
#test "$(md5sum "$existing" | cut -d\ -f1)" = "$(md5sum "$filepath" | cut -d\ -f1)" &&
|
|
|
|
done
|