This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the unix category.
Last Updated: 2025-11-17
I wanted to find how a certain configuration option changed my Webpack output,
which consisted of two files: file1 and file2 (I will use text instead of
JavaScript in the examples)
file1:
this is the original text
line2
line3
line4
happy hacking !
file2 (line3 is deleted and the last line was added)
this is the original text
line2
line4
happy hacking !
GNU is not UNIX
Output of $ diff file1 file2
3d2
< line3
5a5
> GNU is not UNIX
< means first file (file1)> means second file (file2)$ diff -u file1 file2
output:
--- 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,5 relates to file1 and the
part +1,5 to 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:
output:
13. @@ -9,3 +9,4 @@
14. source /home/vagrant/.profile
15.
16. nvm install node
17. +nvm alias default node
nvm alias default node was added.To get colored diff, pipe into vim: $ diff application*.js | nvim -