27

I would like to use diff to compare two directories for differing files, using the -q option for brief output. However, the output is cluttered with a lot of files that only exist in one directory, but not the other. Can I force diff (or use another tool) to only show files that differ AND exist in both directories?

The current command I use is

diff -q <dir1> <dir2>

Any ideas are appreciated.

1 Answers1

27

It prints a bunch of lines like

Only in dir1/blah: blah

right? So just throw them away with grep.

LC_ALL=C diff ... | grep -v '^Only in'

The LC_ALL=C is to make sure that the standard "Only in" message will be printed, not any translation.

Alan Curry
  • 14,255
  • 3
  • 32
  • 33