Last Updated: 2022-05-26
I wanted to find how a certain configuration option changed my Webpack output,
which consisted of two files:
file2 (I will use text instead of
this is the original text line2 line3 line4 happy hacking !
line3 is deleted and the last line was added)
this is the original text line2 line4 happy hacking ! GNU is not UNIX
$ diff file1 file2
3d2 < line3 5a5 > GNU is not UNIX
<means first file (file1)
>means second file (file2)
$ diff -u file1 file2
--- file1 2013-07-06 17:44:59.180000000 +0200 +++ file2 2013-07-06 17:39:53.433000000 +0200 @@ -1,5 +1,5 @@ this is the original text line2 -line3 line4 happy hacking ! +GNU is not UNIX
-in the leftmost column denotes the lines, which were deleted from file1 and
+denotes the lines, which were added.
@@ -1,5 +1,5 @@represents a hunk. The part
-1,5relates to file1 and the part
+1,5to file2 They tell us that diff will show a piece of text, which is 5 lines long starting from line number 1 in file1.txt. And the same about the file2.txt - diff shows us 5 lines starting from line 1.
Here's another example:
13. @@ -9,3 +9,4 @@ 14. source /home/vagrant/.profile 15. 16. nvm install node 17. +nvm alias default node
nvm alias default nodewas added.
To get colored diff, pipe into
$ diff application*.js | nvim -