[EDIT] After posting I noticed @freedo already mentioned
comm before me. [/EDIT]
First store lists of the directory trees into files:
# Using parenthesis ensures the command are executed inside a subshell, so
# changing directory (`cd`) back afterwards is not needed.
(cd dir1 ; find -type d | sort >/tmp/list1)
(cd dir2 ; find -type d | sort >/tmp/list2)
Then this command will show what's present in
dir1 but not in
comm -23 /tmp/list1 /tmp/list2
While this commmand will show what is in
dir2 but not in
comm -13 /tmp/list1 /tmp/list2
And this will show what is present in both:
comm -12 /tmp/list1 /tmp/list2
Finally, this will show all information above at once, in 3 columns:
comm /tmp/list1 /tmp/list2
comm utility seems not be very well known. But it's probably installed by default on most if not all Linux systems. In Debian it's in the "coreutils" package, which is marked "essential".
Little known command, but
comm proved very useful to me once, while I was solving nasty problems in a big filesystem (> 25 Tb). I feel I owe it to
comm to advocate its use.