How can I get diff to show only added and deleted lines
How can I get the unix command diff show only added and deleted lines? If diff can't do it, what tool can?
Solution 1:
I'm not sure this is possible as it will be hard to differentiate between changed, added and deleted lines.
Consider this file:
start
old
old
old
end
We edit it so it looks like this:
start
old
old but now new
new
new
end
If we diff
it we get this output:
< old
< old
---
> old but now new
> new
> new
This is straightforward to generate. But if you ask diff
to only print added and deleted line I think it becomes a matter of opinion which lines have been added and deleted and which have been changed. For example, did I delete the the last line that said old
and replace it with a line that said new
or did I edit it?
Solution 2:
Does diff -u0
do what you want?