I am using this version of diff on my Synology NAS to verify a backup:

xyz> diff
BusyBox v1.16.1 (2014-05-29 11:26:15 CST) multi-call binary.

Usage: diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2

Compare files line by line and output the differences between them.
This implementation supports unified diffs only.

        -a      Treat all files as text
        -b      Ignore changes in the amount of whitespace
        -B      Ignore changes whose lines are all blank
        -d      Try hard to find a smaller set of changes
        -i      Ignore case differences
        -L      Use LABEL instead of the filename in the unified header
        -N      Treat absent files as empty
        -q      Output only whether files differ
        -r      Recurse
        -S      Start with FILE when comparing directories
        -T      Make tabs line up by prefixing a tab when necessary
        -s      Report when two files are the same
        -t      Expand tabs to spaces in output
        -U      Output LINES lines of context
        -w      Ignore all whitespace

Now, I diff'ed two folders on my NAS using diff -q -r /a /b | tee xyz.log. However, this commands seems to only compare the file names, not the files' contents, since it reports Common subdirectories /a/file.ext and /b/file.ext for each and every file pair - that is, around 150.000 times. Why is is not comparing file contents, and which command should I use instead?


I ran into a similar/the same issue with my Synology NAS (BusyBox v1.16.1):

diff -arq Dropbox/abc/ library/abc/ > abc.diff

produced a lot of entries like Common subdirectories: Dropbox/abc/yz/tuv.pdf and library/abc/yz/tuv.pdf even though said file was in xyz/tuv.pdf (x missing).

But the following command (without trailing /) worked as expected:

diff -arq Dropbox/abc library/abc > abc.diff

You are using the diff utility correctly.

It seems that the system calls are reporting that those files are directories instead. This is probably an issue somewhere else in the system, not in busybox diff.

This all comes down to the following lines of code in editors/diff.c:

if (S_ISDIR(stb[0].st_mode) && S_ISDIR(stb[1].st_mode))
                printf("Common subdirectories: %s and %s\n", fullpath[0], fullpath[1]);

Also, if you have any busybox issues you can report to the mailing list, and any busybox diff issues you can report to me directly.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.