Maybe I am missing something, but I'd like a diff between two directories to create files that don't exist, but not remove files that do. So, given something like:
./a/foo
./b/bar
This command:
diff -urN a b
Will show:
diff -urN a/bar b/bar
--- a/bar 1969-12-31 17:00:00.000000000 -0700
+++ b/bar 2012-05-22 10:09:05.221356000 -0600 @@ -0,0 +1 @@
+bar
diff -urN a/foo b/foo
--- a/foo 2012-05-22 10:08:54.133138000 -0600
+++ b/foo 1969-12-31 17:00:00.000000000 -0700 @@ -1 +0,0 @@
-Foo
What I'd like is essentially this:
diff -urN a/bar b/bar
--- a/bar 1969-12-31 17:00:00.000000000 -0700
+++ b/bar 2012-05-22 10:09:05.221356000 -0600 @@ -0,0 +1 @@
+bar
I want new files that are in b but not a to be created, but files that are in a but not b ignored. Is that possible with diff?
Thanks!
Best Answer
I think you're looking for GNU diff's
--unidirectional-new-file
flag, instead of-N
.If you really want to, you can pipe the output through
grep -v '^Only in'
to get rid of the last line, but it shouldn't hurt anything to leave it in.