linux – Efficient way of determining whether 2 directories have ANY difference?

I’d like to recursively compare two directory trees that are expected to be identical, but I don’t want a full comparison which would take forever. I’d like to do an efficient comparison so that as soon as 1 difference is detected, the command stops and returns, and tell me which file was different.

What I consider to be a difference:

  • two files have different content (different timestamps doesn’t matter)
  • a file was found in one directory but not the other (at the exact same path, of course)


  • I don’t need to know the actual differences within the file, just the filepath is enough
  • I tried diff 3.7 on Ubuntu 20.04, it doesn’t have a “stop on difference” option that I could see
  • The files are a mix of text and binary