diff cookies.old cookies.new
5c5
< One cup vanilla extract
---
> One teaspoon vanilla extract
7d6
< Six ounces chopped liver
21a22
Any flags/options can help me get rid of this 5c5, 7d6, 21a22 in output ? What does these characters mean exactly ?
diff cookies.old cookies.new
5c5
< One cup vanilla extract
---
> One teaspoon vanilla extract
7d6
< Six ounces chopped liver
21a22
Any flags/options can help me get rid of this 5c5, 7d6, 21a22 in output ? What does these characters mean exactly ?
Those are the line numbers and the operation to change one to the other. "5c5" means "line five changed (replaced) to line five", "7d6" means "delete line seven", "21a22" means "add (append) line 22"
You can change the output format using options such as --context=NUM
or --unified
.
Here is some more information on output formats from the info
file for diff
.
This command would only show the lines that are different without showing the line number and modification type (it will also eliminate the "----" dividers):
diff cookies.old cookies.new | grep '^[<>]'
http://www.linuxselfhelp.com/gnu/diffutils/html_chapter/diff_3.html
note: "Detailed Description of Normal Format"
Sounds like you just want a more user-friendly diff output. The main reason diff is so percise is because it is used to generate patches. For more user friendly output I recommend:
[kbrandt@alpine: ~/scrap/diff] echo -e 'foo\nbar' > file1
[kbrandt@alpine: ~/scrap/diff] echo -e 'foo\nbaz' > file2
[kbrandt@alpine: ~/scrap/diff] diff -y file1 file2
foo foo
bar | baz
[kbrandt@alpine: ~/scrap/diff] colordiff -y file1 file2
Colordiff will give you the side by side output but with lines in different colors to give more emphasis to the differences.
Numbers are used to identify the offset of the file where the difference occurs.
Check diff man page or