From c41fb53394fc63453c7ccb27544d67c90f686383 Mon Sep 17 00:00:00 2001 From: luinia Date: Wed, 14 Nov 2018 17:28:46 +0000 Subject: [PATCH] advanced: diff git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@181 a672b425-5310-4d7a-af5c-997e18724b81 --- site/pages/cmd/advanced/diff.html | 168 ++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 site/pages/cmd/advanced/diff.html diff --git a/site/pages/cmd/advanced/diff.html b/site/pages/cmd/advanced/diff.html new file mode 100644 index 0000000..96007a5 --- /dev/null +++ b/site/pages/cmd/advanced/diff.html @@ -0,0 +1,168 @@ +--- +layout: page +author: Alessandro Luini +category-page: advanced +category-title: Advanced commands +tags: difference lines diff file separating +title: diff +--- + + + + + +

diff analyzes two files and prints the lines that are different. + Essentially, it outputs a set of instructions for how to change one file to + make it identical to the second file.

+ + + + + + + +

How to use

+ +

To activate the diff command, we must take as parameters two or more + files that we want to compare and it will give us the output of + different lines.
+ For example let's say we have two files, file1.txt and file2.txt.
+
If file1.txt contains the following four lines of text:

+ +
  1. I need to buy apples.
  2. +
  3. I need to run around the park.
  4. +
  5. I need to wash the dog.
  6. +
  7. I need to get the car detailed.
+ +

...and file2.txt contains these four lines:

+ +
  1. I need to buy apples.
  2. +
  3. I need to do the laundry.
  4. +
  5. I need to wash the dog.
  6. +
  7. I need to get the dog detailed.
+ +

...then we can use diff to automatically display for us which lines differ + between the two files with this command:

+ +
diff file1.txt file2.txt
+ +

...and the output will be:

+ +
 2,4c2,4 
+< I need to run the laundry.
+< I need to wash the dog.
+< I need to get the car detailed.
+---
+> I need to do the laundry.
+> I need to wash the car.
+> I need to get the dog detailed.
+ +

In our output above, "2,4c2,4" means: "Lines 2 through 4 in the first + file need to be changed to match lines 2 through 4 in the second file.

+ + + + + + + +

Flags

+