Diff Command – Shows a File That Does Not Exist

diff()filenames

I created a backup on an external hard disc. Then I created another backup and copied all files to another external hard disc. I wanted to check with diff if everything was copied:

user@user:/media/user$ diff -r backup backup1
Nur in backup1/home/user: file.xls.
Nur in backup1/home/user: file.zip.

("nur" is German for "only".)

The diff shows two files that are not existing:

user@user:/media/user$ file backup1/home/user/file.xls.
backup1/home/user/file.xls.: cannot open backup1/home/user/file.xls. (No such file or directory)
user@user:/media/user$ file backup1/home/user/file.zip.
backup1/home/user/file.zip.: cannot open backup1/home/user/file.zip. (No such file or directory)

How does it come that diff shows these two files, and how can I fix the output of diff?
The filesystem is LUKS on both external hard drives.

Best Answer

The output of diff -r with a German locale adds a . to the file.
Files backup1/home/user/file.xls and backup1/home/user/file.zip should exist.

Example:

$ mkdir dir1 dir2
$ touch dir1/foo
$ LANG=de_DE.UTF8 diff -r dir1 dir2
Nur in dir1: foo.
$ diff -r dir1 dir2
Only in dir1: foo
Related Question