How to make a "diff" command including an empty file when creating a patch file

The Linux-system assume that there are 2 folders and one empty file fld1

, fld1/__init__.py

and fld2

(here __init__.py

- an empty file created by "touch" command).

Then I create a patch file with the command diff -urNp fld1 fld2 > tmp.patch

. No differences were found in tmp.patch

.

If I remove the "-N" option and only use it diff -urp fld1 fld2 > tmp.patch

, it can tell the difference, but it only shows: "Only in fld1: __init__.py" which is not the correct patch format.

To work around this problem, I add one new line in __init__.py

as a workaround. then "-urNp" works as expected.

But I still want to know: how can I use "diff" to generate a correct patch file that also includes empty files?

+3


source to share





All Articles