Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 @@
@@ -168,2 +167,2 @@

[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
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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .