Use Linux diff command to compare files line by line. This handy tool helps you identify line differences between files and console output.

Command

diff -y file1 file1

Marker Meaning

| = line present in both files but the text differs.
< = line present only in the left file.
> = line present only in the right file.

Examples

Comparing two package.json files

johnpili@com ~ % diff -y package1.json package2.json                                 
{								{
  "name": "date-diff",					      |	  "name": "time-zones",
  "version": "0.0.0",						  "version": "0.0.0",
  "scripts": {							  "scripts": {
    "ng": "ng",							    "ng": "ng",
    "start": "ng serve",					    "start": "ng serve",
    "build": "ng build --base-href /tools/date-diff/ --config |	    "build": "ng build",
    "watch": "ng build --watch --configuration development",	    "watch": "ng build --watch --configuration development",
    "test": "ng test"						    "test": "ng test"
  },								  },
  "private": true,						  "private": true,
  "dependencies": {						  "dependencies": {
    "@angular/common": "^19.2.0",				    "@angular/common": "^19.2.0",
    "@angular/compiler": "^19.2.0",				    "@angular/compiler": "^19.2.0",
    "@angular/core": "^19.2.0",					    "@angular/core": "^19.2.0",
    "@angular/forms": "^19.2.0",				    "@angular/forms": "^19.2.0",
    "@angular/platform-browser": "^19.2.0",			    "@angular/platform-browser": "^19.2.0",
    "@angular/platform-browser-dynamic": "^19.2.0",		    "@angular/platform-browser-dynamic": "^19.2.0",
    "@angular/router": "^19.2.0",				    "@angular/router": "^19.2.0",
    "@tailwindcss/postcss": "^4.1.4",				    "@tailwindcss/postcss": "^4.1.4",
    "daisyui": "^5.0.28",					    "daisyui": "^5.0.28",
    "moment": "^2.30.1",				      |	    "moment-timezone": "^0.5.48",
    "postcss": "^8.5.3",					    "postcss": "^8.5.3",
    "rxjs": "~7.8.0",						    "rxjs": "~7.8.0",
    "tailwindcss": "^4.1.4",					    "tailwindcss": "^4.1.4",
    "tslib": "^2.3.0",						    "tslib": "^2.3.0",
    "zone.js": "~0.15.0"					    "zone.js": "~0.15.0"
  },								  },
  "devDependencies": {						  "devDependencies": {
    "@angular-devkit/build-angular": "^19.2.8",			    "@angular-devkit/build-angular": "^19.2.8",
    "@angular/cli": "^19.2.8",					    "@angular/cli": "^19.2.8",
    "@angular/compiler-cli": "^19.2.0",				    "@angular/compiler-cli": "^19.2.0",
    "@types/jasmine": "~5.1.0",					    "@types/jasmine": "~5.1.0",
    "jasmine-core": "~5.6.0",					    "jasmine-core": "~5.6.0",
    "karma": "~6.4.0",						    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",				    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",					    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",					    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",			    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.7.2"					    "typescript": "~5.7.2"
  }								  }
}								}
johnpili@com ~ %

The example below shows how to use diff to compare installed PHP modules. This is very useful when you’re switching to a different version of PHP

johnpili@com:~$ diff -y <(php8.0 -m) <(php8.4 -m)
[PHP Modules]							[PHP Modules]
calendar							calendar
Core								Core
ctype								ctype
curl								curl
date								date
dom								dom
exif								exif
FFI								FFI
fileinfo							fileinfo
filter								filter
ftp								ftp
gd								gd
gettext								gettext
hash								hash
iconv								iconv
>	intl
json								json
libxml								libxml
>	mbstring
mysqli								mysqli
mysqlnd								mysqlnd
openssl								openssl
pcntl								pcntl
pcre								pcre
PDO								PDO
pdo_mysql							pdo_mysql
Phar								Phar
posix								posix
>	random
readline							readline
Reflection							Reflection
session								session
shmop								shmop
SimpleXML							SimpleXML
sockets								sockets
sodium								sodium
SPL								SPL
standard							standard
sysvmsg								sysvmsg
sysvsem								sysvsem
sysvshm								sysvshm
tokenizer							tokenizer
>	uploadprogress
xml								xml
xmlreader							xmlreader
xmlwriter							xmlwriter
xsl								xsl
Zend OPcache							Zend OPcache
zip								zip
zlib								zlib

[Zend Modules]							[Zend Modules]
Zend OPcache							Zend OPcache

johnpili@com:~$