I have an assignment for school. One part of it is to check a file for changes and write these changes to a log file. So far I've found the diff
command which could be helpful in my opinion. Let's say I have two files with content like this:
file1
orange
apple
file2
orange
apple
strawberry
If I use diff -c file1 file2
in this case, the output of the command is
*** file1 2016-11-24 08:31:19.424712242 +0100
--- file2 2016-11-24 08:25:24.604681751 +0100
***************
*** 1,2 ****
--- 1,3 ----
orange
apple
+ strawberry
which I think says that line with '+' sign needs to be added to file1 for them to be the same(?).
Now let's say I change file1 to this:
orange
apple
peach
The output of diff -c file1 file2
is:
*** file1 2016-11-24 08:34:50.647128312 +0100
--- file2 2016-11-24 08:25:24.604681751 +0100
***************
*** 1,3 ****
orange
apple
! peach
--- 1,3 ----
orange
apple
! strawberry
And here I'm lost, because I don't understand what these exclamation marks mean. Suddenly, the diff command seems not so helpful. I've tried looking at the man page of diff command, but can't find anything (maybe I just don't see it).
-c
was widely available, and-u
was gradually making inroads. I remember when I first got access to unified diffs; it felt like a great privilege was bestowed upon me! – Toby Speight Nov 18 '22 at 19:04