I am doing diff -rq to check the difference between 2 folders (A and B). I don't want to know if folder A has any new files because that's expected. How do I ensure that this information doesn't come up?
1 Answer
Expanding on my comment now that I'm at an actual keyboard:
The only way to do what you want is to diff files individually. We can combine find and xargs to do that, something like this:
(cd B && find . -type f -print0) | xargs -0 -IPATH diff -q A/PATH B/PATH
This produces a list of all files in B relative to the top directory, and the uses xargs to run a series of diff -q commands comparing the file in B to the same path in A.
When the directories have identical content, it produces no output and the return code is 0:
$ (cd B && find . -type f -print0) | xargs -0 -IPATH diff -q A/PATH B/PATH
$ echo $?
0
When there are differences, diff -q prints a message to the console, and the return code is 123:
$ (cd B && find . -type f -print0) | xargs -0 -IPATH diff -q A/PATH B/PATH
Files A/./dir2/dir3/file1 and B/./dir2/dir3/file1 differ
$ echo $?
123
diff -rqyou could perform afind . -type f ...in B, and then compare those files against the same files in A.grep -v "Only in A:"on yourdiff -rq A Bcommand?