2

dir1 has 1 file and dir2 has 2 files as below:

/tmp$ ls dir1
file1
/tmp$ cat dir1/file1 
line1
line2
line3
/tmp$ ls dir2
file1  file2
/tmp$ cat dir2/file1 
line1
/tmp$ cat dir2/file2
line1
/tmp$ diff -ur dir1 dir2 | diffstat
 file1 |    2 --
 file2 |only
 2 files changed, 2 deletions(-)

I am looking for a command to print the lines in dir2 new files as insertions(+)

dir2/file2 has one line, so I am looking to print

2 files changed, 2 deletions(-), 1 insertions(+)

This question is relevant to Diff of directory statistics sumarry (git diff --stat like for non-git repo)

Thanks!

2 Answers 2

3

You need to use the -N (treat missing files as empty) option to diff. For example:

$ diff -N -u -r dir1/ dir2/ | diffstat 
 file1 |    2 --
 file2 |    1 +
 2 files changed, 1 insertion(+), 2 deletions(-)
0

Have you tried plain diff against them? diff -u dir1 dir2

If you have a GUI, check out kompare (sometimes in the kdesdk RPM) and/or meld for something much nicer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .