Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When using diff, is there a way to suppress the first two lines (listing the file names and times) and all the lines beginning with @@ in the output? All I want are the lines that show what to delete and what to add.

Here's the command I have currently:

diff file1 file2 -U 0 > output.txt

Sample output of what I get in the output.txt file with that command:

--- file1   2010-11-25 01:56:58.856462432 -0500
+++ file2   2010-11-25 01:57:20.100626348 -0500
@@ -145,2 +145 @@
-VI2
-US3
+VI4
@@ -168,2 +167,2 @@
-56VI
-56PR
+57VI
+57PR

[edit]: whomever it was that added the comm command, it actually ended up being correct. I'll award you the answer if you post it back.

share|improve this question
add comment

2 Answers

diff file1 file2 -U 0 | tail +3 | grep -v "^@@" > output.txt

This version has the same diff command you have, but strips the first two lines with tail (starting from third line) and outputs only lines not having "@@" at the beginning.

share|improve this answer
add comment
up vote 0 down vote accepted

This ended up being the solution I went with:

comm -1 -3 --nocheck-order 'path/file.csv' 'path/file2.csv' > 'path/added.txt'
comm -2 -3 --nocheck-order 'path/file.csv' 'path/file2.csv' > 'path/removed.txt'
share|improve this answer
add comment

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.