if the problem could be solved using a series of commands on the command line, it would be better for me than writing a script
Asked
Active
Viewed 430 times
0
2 Answers
1
for x in *; do for y in *; do [ "$x" = "$y" ] && continue; cmp -s "$x" "$y" && echo Same: "$x" and "$y"; done; done|head -1
Or, broken up a bit for readability:
for x in *
do
for y in *
do
[ "$x" = "$y" ] && continue
cmp -s "$x" "$y" && echo Same: "$x" and "$y"
done
done | head -1
The head
is just to keep the mirror reporting down ("a = b" and "b = a").

Jeff Schaller
- 67,283
- 35
- 116
- 255
1
find . -type f -exec md5sum "{}" \; | awk 'seen[$1] { print "Duplicate file "$2" with hash "$1" at "seen[$1]" } ! seen[$1] {seen[$1]=$2}'

DopeGhoti
- 76,081
-
It says "Duplicate file xxx with hash yyy". That's right. But duplicate to what file? But nicely scripted! – Freddy Jan 28 '19 at 18:55
-
Tweaked to store the first filename found in the array for reference in the output. – DopeGhoti Jan 28 '19 at 20:17
diff
command. You would probably have to construct afor
loop to compare each file in the directory to every other. Could do it with a fairly simple script. – Time4Tea Jan 28 '19 at 18:05