0

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

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • Hi and welcome to Unix Stack Exchange. I think to do this, you would need to use the diff command. You would probably have to construct a for 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

2 Answers2

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