Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing "Common subdirectories:" in diff command

Tags:

linux

diff

I'm trying to use the diff command to see the difference between two directories, recursively.

aDirectory under directory directory1 and aDirectory under directory directory2:

diff "directory1/aDirectory" "directory2/aDirectory"

Each of those have subdirectories and that's fine. For each common subdirectory I get this:

Common subdirectories: directory1/aDirectory/dir and directory1/aDirectory/dir

Because I have so many identically named subdirectories, notification about common subdirectories is annoying and makes the output unreadable.

All I want the diff command to show me are files/subdirectories that are different between those two directories (and their subdirectories), but not the ones that are the same. Is there a switch for that?

like image 624
john_black Avatar asked Sep 05 '18 11:09

john_black


1 Answers

You need to supply the -r option to do a recursive diff. Without it, diff is telling you that "directory1/aDirectory" and "directory2/aDirectory" both have a subdirectory called "dir". However, it is not looking inside "dir", because you did not ask for recursive diff.

Try

diff -r "directory1/aDirectory" "directory2/aDirectory"
like image 109
wrdieter Avatar answered Sep 29 '22 15:09

wrdieter