Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
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 ?

share|improve this question

4 Answers 4

up vote 1 down vote accepted

http://www.linuxselfhelp.com/gnu/diffutils/html_chapter/diff_3.html

note: "Detailed Description of Normal Format"

share|improve this answer

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.

share|improve this answer

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 '^[<>]'
share|improve this answer

Numbers are used to identify the offset of the file where the difference occurs.

Check diff man page or

http://ss64.com/bash/diff.html

http://en.wikipedia.org/wiki/Diff

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.