1

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.

2 Answers 2

2
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.

0

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'

You must log in to answer this question.

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