---
title: "How to Compare Files Using diff Command in Linux"
description: "Compare files in Linux best examples."
url: https://srinimf.com/2015/09/19/how-to-compare-two-files-in-unix-with-diff-command/
date: 2015-09-19
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2015/09/diff_command-in-linux.jpg?fit=1200%2C700&ssl=1
categories: ["UNIX"]
tags: ["Comparing two files in UNIX"]
type: post
lang: en
---

# How to Compare Files Using diff Command in Linux

The “**diff command**” compares two files, returns the line(s) that are different, and tells you [how to](https://srinimf.com/2019/11/12/ubuntu-tutorial-cut-command-on-csv-file/) make the files the same.

**Here’s an example to use ‘diff’ command**

```
$ diff file1 file2
```

> Here, File1 and File 2 are two files taken for comparison. The UNIX assigns for file 1 ‘A’ and for File 2 ‘B’. Then it gives clear differences.

Refer [more for diff commands](http://www.itworld.com/article/2696092/operating-systems/unix---having-fun-with-diff.html)

Recent Posts

Related[9 Features of Linux Operating System](https://srinimf.com/2019/03/02/9-linux-tricky-points-every-user-must-know/)

- [How to Find Databricks Job Status, Owner, and Active Runs Fast](https://srinimf.com/2026/10/17/databricks-find-job-status/)
- [30 SQL Practice Queries with Solutions — Run Them Live](https://srinimf.com/2026/10/01/30-sql-practice-queries-with-solutions-run-them-live/)
- [Supercharge Your Database Skills: Try Our New Interactive SQL Plugin!](https://srinimf.com/2026/09/30/supercharge-your-database-skills-try-our-new-interactive-sql-plugin/)

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2015%2F09%2F19%2Fhow-to-compare-two-files-in-unix-with-diff-command%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2015%2F09%2Fdiff_command-in-linux.jpg%3Ffit%3D1200%252C700%26ssl%3D1&description=How%20to%20Compare%20Files%20Using%20diff%20Command%20in%20Linux)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2015/09/19/how-to-compare-two-files-in-unix-with-diff-command/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2015/09/19/how-to-compare-two-files-in-unix-with-diff-command/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2015/09/19/how-to-compare-two-files-in-unix-with-diff-command/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2015/09/19/how-to-compare-two-files-in-unix-with-diff-command/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Compare%20Files%20Using%20diff%20Command%20in%20Linux&body=https%3A%2F%2Fsrinimf.com%2F2015%2F09%2F19%2Fhow-to-compare-two-files-in-unix-with-diff-command%2F&share=email)
-

### Like this:

Like Loading…
