{"id":3054,"date":"2023-01-05T11:26:08","date_gmt":"2023-01-05T11:26:08","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=3054"},"modified":"2023-08-30T05:38:38","modified_gmt":"2023-08-30T05:38:38","slug":"diff-command-in-linux","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/diff-command-in-linux\/","title":{"rendered":"The \u201cdiff\u201d Command in Linux [11 Practical Examples]"},"content":{"rendered":"<p style=\"text-align: justify;\">The <strong>diff<\/strong> command in <strong>Linux<\/strong> is a utility tool that allows you to compare files from the <strong>command line<\/strong>. It displays the result on your terminal and provides several <strong>instructions<\/strong> to modify a file from the <strong>command line<\/strong>. You will need to understand the <strong>symbols<\/strong> and <strong>options<\/strong> to use this command. In this article, I will explain the frequent uses of the diff command with practical examples.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#A_Description\" >A. Description<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#B_Syntax\" >B. Syntax<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#C_Options\" >C. Options<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#D_Symbols\" >D. Symbols<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Practical_Examples_of_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\" >Practical Examples of the \u201cdiff\u201d Command in Linux<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_1_Displaying_Differences_Between_Files_and_Instructions_to_Make_the_1st_File_Similar\" >Example 1: Displaying Differences Between Files and Instructions to Make the 1st File Similar<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_2_Displaying_the_File_Differences_and_Instructions_in_Separate_Contexts\" >Example 2: Displaying the File Differences and Instructions in Separate Contexts<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_3_Displaying_the_File_Differences_and_Instructions_in_a_Unified_Context\" >Example 3: Displaying the File Differences and Instructions in a Unified Context<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_4_Printing_Out_File_Differences_Side_by_Side_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\" >Example 4: Printing Out File Differences Side by Side Using the \u201cdiff\u201d Command in Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_5_Checking_If_Two_Files_Differ_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\" >Example 5: Checking If Two Files Differ Using the \u201cdiff\u201d Command in Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_6_Checking_If_Two_Files_are_Identical_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\" >Example 6: Checking If Two Files are Identical Using the \u201cdiff\u201d Command in Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_7_Case-Insensitive_File_Comparisons_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\" >Example 7: Case-Insensitive File Comparisons Using the \u201cdiff\u201d Command in Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_8_Ignoring_White_Spaces_While_Differentiating_Files_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\" >Example 8: Ignoring White Spaces While Differentiating Files Using the \u201cdiff\u201d Command in Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_9_Ignoring_Blank_Lines_While_Differentiating_Files_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\" >Example 9: Ignoring Blank Lines While Differentiating Files Using the \u201cdiff\u201d Command in Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_10_Comparing_Two_Directories_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\" >Example 10: Comparing Two Directories Using the \u201cdiff\u201d Command in Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Example_11_Redirecting_Output_of_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\" >Example 11: Redirecting Output of the \u201cdiff\u201d Command in Linux<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"A_Description\"><\/span>A. Description<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The <strong>diff<\/strong> command in <strong>Linux <\/strong>compares files line by line<strong>. <\/strong>It can also differentiate between the contents within directories.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"B_Syntax\"><\/span>B. Syntax<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The syntax of the <strong>diff <\/strong>command in <strong>Linux<\/strong> simply contains single or multiple <strong>options<\/strong> and then the desired <strong>Filenames<\/strong>.<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff [OPTION]... FILES<\/code><\/pre>\n<div class=\"su-note\"  style=\"border-color:#cedfe2;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#E8F9FC;border-color:#ffffff;color:#333333;\"><strong>Note: <\/strong>In the above syntax<strong> OPTION<\/strong> enclosed by a square bracket and followed by 3 dots represents that multiple options can be utilized simultaneously.<\/div><\/div>\n<h3><span class=\"ez-toc-section\" id=\"C_Options\"><\/span>C. Options<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The <strong>diff<\/strong> command in <strong>Linux <\/strong>offers several <strong>options<\/strong> to modify your experience of differentiating files. However, you will find the most useful ones here for your convenience. For any further features, you can always look at the <strong>man page.<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">man diff<\/code><\/pre>\n<p><span style=\"color: #800080;\"><strong>Useful Options<\/strong><\/span><\/p>\n<div class=\"su-list\" style=\"margin-left:20px\">\n<ul>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>-B <\/strong>( Ignores blank lines )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>-c <\/strong>( Displays copied context )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>-i <\/strong>( Ignores case differences )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>-r <\/strong>( Recursively compares subdirectories )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>-s <\/strong>( Reports if files are identical )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>-q <\/strong>( Reports if files are different )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>-u <\/strong>( Displays unified context )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>-w <\/strong>( Ignores all white spaces )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>-y <\/strong>( Displays results in two columns )<\/li>\n<\/ul>\n<\/div>\n<div class=\"su-note\"  style=\"border-color:#cedfe2;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#E8F9FC;border-color:#ffffff;color:#333333;\"><strong>NB:<\/strong> The <strong>options<\/strong> in <strong>Linux<\/strong> <strong>CLI (Command Line Interface)<\/strong> are all <strong>case-sensitive<\/strong>, So be cautious while using them.<\/div><\/div>\n<h3><span class=\"ez-toc-section\" id=\"D_Symbols\"><\/span>D. Symbols<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The <strong>diff<\/strong> command in <strong>Linux <\/strong>uses a number of <strong>symbols<\/strong> to represent the differences between two files. The <strong>symbols<\/strong> also indicate instructions. Below are some <strong>symbols<\/strong> used by the <strong>diff<\/strong> command. You will find more information on the <strong>man page<\/strong> of the command.<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">man diff<\/code><\/pre>\n<p><span style=\"color: #800080;\"><strong>Useful Symbols<\/strong><\/span><\/p>\n<div class=\"su-list\" style=\"margin-left:20px\">\n<ul>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>a\/+ <\/strong>( Indicates addition of content )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>c\/! <\/strong>( Indicates change of content )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>d\/- <\/strong>( Indicates deletion of content )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>&gt;<\/strong> ( Lines from 1st File )<\/li>\n<li><i class=\"sui sui-arrow-right\" style=\"color:#000000\"><\/i> <strong>&lt; <\/strong>( Lines from 2nd File )<\/li>\n<\/ul>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Practical_Examples_of_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\"><\/span>Practical Examples of the \u201cdiff\u201d Command in Linux<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The <strong>diff <\/strong>command in <strong>Linux<\/strong> is a convenient command used to find the similarities or dissimilarities between file contents. Some of the most helpful applications of the <strong>diff <\/strong>command have been illustrated here. You can download the files associated with the examples from below.<\/p>\n<div class=\"su-button-center\"><a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/TextFiles.zip\" class=\"su-button su-button-style-default\" style=\"color:#000000;background-color:#E8F9FF;border-color:#bac8cc;border-radius:56px\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color:#000000;padding:8px 26px;font-size:20px;line-height:30px;border-color:#effbff;border-radius:56px;text-shadow:0px 0px 0px #000000\"><i class=\"sui sui-download\" style=\"font-size:20px;color:#1AA1D6\"><\/i> Download this file to work with the \u201cdiff\u201d command in Linux.<\/span><\/a><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Example_1_Displaying_Differences_Between_Files_and_Instructions_to_Make_the_1st_File_Similar\"><\/span>Example 1: Displaying Differences Between Files and Instructions to Make the 1st File Similar<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">You can display differences between files using the <strong>diff<\/strong> command in <strong>Linux<\/strong>. The command will also give you instructions using <strong>symbols<\/strong> to reduce differences. In this example, I will demonstrate how the <strong>diff<\/strong> command presents differences and <strong>instructions<\/strong>. I will use two text files \u201c<strong>file1.txt<\/strong>\u201d and \u201c<strong>file2.txt<\/strong>\u201d. To do so you can follow the steps below.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff file1.txt file2.txt<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In this first image, I have shown you the contents of the file using the <strong>cat <\/strong>command for better understanding.<img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-3081\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1.png\" alt=\"Displaying file contents using cat command.\" width=\"431\" height=\"341\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1.png 431w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-300x237.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-1024x810.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-767x607.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-1536x1215.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-2048x1620.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-190x150.png 190w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-100x79.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-442x350.png 442w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-788x623.png 788w\" sizes=\"(max-width: 431px) 100vw, 431px\" \/>In this second image, you can see that the <strong>diff<\/strong> command resulted in three <strong>instructions<\/strong> for the differences encountered in each line. All the instructions are only applicable to the 1st file \u201c<strong>file1.txt<\/strong>\u201d.<img decoding=\"async\" class=\"aligncenter wp-image-3082 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2.png\" alt=\"Displaying file differences with instructions using diff command in Linux.\" width=\"554\" height=\"338\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2.png 554w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2-300x183.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2-1024x625.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2-767x468.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2-1536x937.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2-2048x1250.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2-246x150.png 246w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2-100x61.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2-574x350.png 574w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-2-788x480.png 788w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><\/p>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p>Explanations of each <strong>instruction<\/strong> are given below.<\/p>\n<ul>\n<li style=\"text-align: justify;\"><strong>0a1<\/strong>: After line <strong>0<\/strong> ( at the beginning of the file ) <strong>add(a)<\/strong> the <strong>1st<\/strong> line from the second file which is \u201c<strong>Dhaka<\/strong>\u201d.<\/li>\n<li style=\"text-align: justify;\"><strong>2c3<\/strong>: <strong>Change(c)<\/strong> the <strong>2nd<\/strong> line \u201c<strong>Cumilla<\/strong>\u201d into the <strong>3rd<\/strong> line \u201c<strong>Comilla<\/strong>\u201d of the second file.<\/li>\n<li style=\"text-align: justify;\"><strong>4,5c5,6<\/strong>: <strong>Change(c)<\/strong> the <strong>4th,5th<\/strong> lines \u201c<strong>Chattogram<\/strong>\u201d, \u201c<strong>Kushtia<\/strong>\u201d into the <strong>5th,6th<\/strong> lines of the second file. Lines from the second file are \u201c<strong>Chittagong<\/strong>\u201d and \u201c<strong>Khulna<\/strong>\u201d.<\/li>\n<\/ul>\n<\/div><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Example_2_Displaying_the_File_Differences_and_Instructions_in_Separate_Contexts\"><\/span>Example 2: Displaying the File Differences and Instructions in Separate Contexts<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">You can display differences between files in the file&#8217;s default context using the <strong>diff<\/strong> command in <strong>Linux <\/strong>with option<strong> -c<\/strong>. The command will show you dissimilarities between the 1st file with the 2nd file using <strong>symbols<\/strong>. These <strong>symbols<\/strong> also indicate <strong>instructions<\/strong> for making the files similar. In this example, I will differentiate two text files: \u201c<strong>file1.txt<\/strong>\u201d and \u201c<strong>file2.txt<\/strong>\u201d in copied context and explain the resulting symbols. To do so you can follow the steps below.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff -c file1.txt file2.txt<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In this first image, I have shown you the contents of the file using the <strong>cat <\/strong>command for better understanding.<img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-3081\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1.png\" alt=\"Displaying file contents using cat command.\" width=\"431\" height=\"341\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1.png 431w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-300x237.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-1024x810.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-767x607.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-1536x1215.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-2048x1620.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-190x150.png 190w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-100x79.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-442x350.png 442w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-788x623.png 788w\" sizes=\"(max-width: 431px) 100vw, 431px\" \/>In this second image, you can see that the <strong>diff<\/strong> command is showing two kinds of <strong>symbols <\/strong>for the differences encountered in each line. The <strong>instructions<\/strong> given using the <strong>symbols<\/strong> are only applicable to the 1st file \u201c<strong>file1.txt<\/strong>\u201d.<img decoding=\"async\" class=\"aligncenter wp-image-3083 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3.png\" alt=\"Displaying file differences in copied context using diff command in Linux.\" width=\"671\" height=\"446\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3.png 671w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3-300x199.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3-1024x681.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3-767x510.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3-1536x1021.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3-2048x1361.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3-226x150.png 226w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3-100x66.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3-527x350.png 527w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-3-788x523.png 788w\" sizes=\"(max-width: 671px) 100vw, 671px\" \/><\/p>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">Explanations of each <strong>symbol<\/strong> are given below.<\/p>\n<ul>\n<li style=\"text-align: justify;\"><strong>+<\/strong>: <strong>Add(+)<\/strong> \u201c<strong>Dhaka<\/strong>\u201d to the corresponding line of the first file.<\/li>\n<li style=\"text-align: justify;\"><strong>!<\/strong>: <strong>Change(!)<\/strong> the lines from the first file into the <strong>(!)<\/strong> assigned lines of the second file.<\/li>\n<\/ul>\n<\/div><\/div>\n<hr \/>\n<p><span style=\"color: #000080; font-size: 18pt;\"><strong>Similar Readings<\/strong><\/span><\/p>\n<ul>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/pwd-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201cpwd\u201d Command in Linux [4 Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/cd-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201ccd\u201d Command in Linux [6 Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/ls-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201cls\u201d Command in Linux [7+ Practical Examples]<\/a><\/strong><\/li>\n<\/ul>\n<hr \/>\n<h3><span class=\"ez-toc-section\" id=\"Example_3_Displaying_the_File_Differences_and_Instructions_in_a_Unified_Context\"><\/span>Example 3: Displaying the File Differences and Instructions in a Unified Context<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Using the <strong>diff<\/strong> command in <strong>Linux <\/strong>with option<strong> -u <\/strong>you can display differences between files in a unified context. The command will show you dissimilarities between the 1st file with the 2nd file using <strong>symbols<\/strong>. These <strong>symbols<\/strong> also indicate <strong>instructions<\/strong> for making the files similar. In this example, I will differentiate two text files: \u201c<strong>file1.txt<\/strong>\u201d and \u201c<strong>file2.txt<\/strong>\u201d in copied context and explain the resulting symbols. To do so you can follow the steps below.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff -u file1.txt file2.txt<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In this first image, I have shown you the contents of the file using the <strong>cat <\/strong>command for better understanding.<img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-3081\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1.png\" alt=\"Displaying file contents using cat command.\" width=\"431\" height=\"341\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1.png 431w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-300x237.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-1024x810.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-767x607.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-1536x1215.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-2048x1620.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-190x150.png 190w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-100x79.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-442x350.png 442w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-1-788x623.png 788w\" sizes=\"(max-width: 431px) 100vw, 431px\" \/>In this second image, you can see that the <strong>diff<\/strong> command is showing two kinds of <strong>symbols <\/strong>for the differences encountered in each line. The <strong>instructions<\/strong> given using the <strong>symbols<\/strong> are only applicable to the 1st file \u201c<strong>file1.txt<\/strong>\u201d.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3084 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4.png\" alt=\"Displaying file differences in unified context using diff command in Linux.\" width=\"673\" height=\"340\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4.png 673w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4-300x152.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4-1024x517.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4-766x387.png 766w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4-1536x776.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4-2048x1035.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4-297x150.png 297w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4-100x51.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4-693x350.png 693w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-4-788x398.png 788w\" sizes=\"(max-width: 673px) 100vw, 673px\" \/><\/p>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">Explanations of each <strong>symbol<\/strong> are given below.<\/p>\n<ul>\n<li style=\"text-align: justify;\"><strong>+<\/strong>: <strong>Add(+)<\/strong> the <strong>(+)<\/strong> assigned lines to the first file.<\/li>\n<li style=\"text-align: justify;\"><strong>&#8211;<\/strong>: <strong>Delete(-)<\/strong> the <strong>(-)<\/strong> assigned lines from the first file.<\/li>\n<\/ul>\n<\/div><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Example_4_Printing_Out_File_Differences_Side_by_Side_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\"><\/span>Example 4: Printing Out File Differences Side by Side Using the \u201cdiff\u201d Command in Linux<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Using the <strong>diff<\/strong> command in <strong>Linux <\/strong>with the option<strong> -y <\/strong>you can display differences between files in side-by-side columns. The command assigns <strong>symbols <\/strong>to the contents of the second file to indicate the differences. These <strong>symbols<\/strong> also represent <strong>instructions<\/strong> for making the files similar. In this example, I will display the differences between the two text files: \u201c<strong>file1.txt<\/strong>\u201d and \u201c<strong>file2.txt<\/strong>\u201d in adjacent columns. You can do the same by following the given steps.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff -y file1.txt file2.txt<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In this image, I have shown the contents of the files in side-by-side columns. The differences are indicated by <strong>(&gt;)<\/strong> and <strong>(|)<\/strong>\u00a0 symbols.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3088 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8.png\" alt=\"Viewing file contents side-by-side using diff command in Linux.\" width=\"825\" height=\"156\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8-300x57.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8-1024x194.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8-767x145.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8-1536x290.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8-2048x387.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8-793x150.png 793w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8-100x19.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8-1851x350.png 1851w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-8-788x149.png 788w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_5_Checking_If_Two_Files_Differ_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\"><\/span>Example 5: Checking If Two Files Differ Using the \u201cdiff\u201d Command in Linux<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">You can check if two files are different using the <strong>diff<\/strong> command in <strong>Linux<\/strong> with the option <strong>-q<\/strong>. In this example, I will check if the two text files \u201c<strong>file3.txt<\/strong>\u201d and \u201c<strong>file4.txt<\/strong>\u201d are different. To do so you can follow the steps below.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff -q file3.txt file4.txt<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In the image below, at first, I showed the contents of the file using the <strong>cat <\/strong>command. Then I displayed that the two files are different.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3141 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13.png\" alt=\"Checking different files using diff command in Linux. \" width=\"596\" height=\"370\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13.png 596w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13-300x186.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13-1024x636.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13-767x476.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13-1536x954.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13-2048x1271.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13-242x150.png 242w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13-100x62.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13-564x350.png 564w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-13-788x489.png 788w\" sizes=\"(max-width: 596px) 100vw, 596px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_6_Checking_If_Two_Files_are_Identical_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\"><\/span>Example 6: Checking If Two Files are Identical Using the \u201cdiff\u201d Command in Linux<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">You can check if the contents in two files are the same using the <strong>diff<\/strong> command in <strong>Linux<\/strong> with the option <strong>-s<\/strong>. In this example, I will check if the two text files \u201c<strong>file5.txt<\/strong>\u201d and \u201c<strong>file6.txt<\/strong>\u201d are identical. To do so you can follow the steps below.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff -s file5.txt file6.txt<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In the image below, at first, I showed the contents of the file using the <strong>cat <\/strong>command. Then I displayed that the two files are identical.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3142 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14.png\" alt=\"Checking identical files using diff command in Linux.\" width=\"603\" height=\"318\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14.png 603w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14-300x158.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14-1024x540.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14-768x405.png 768w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14-1536x810.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14-2048x1080.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14-284x150.png 284w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14-100x53.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14-664x350.png 664w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-14-788x415.png 788w\" sizes=\"(max-width: 603px) 100vw, 603px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_7_Case-Insensitive_File_Comparisons_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\"><\/span>Example 7: Case-Insensitive File Comparisons Using the \u201cdiff\u201d Command in Linux<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">You can compare the contents in two files ignoring the case using the <strong>diff<\/strong> command in <strong>Linux<\/strong> with the option <strong>-i<\/strong>. In this example, I will compare the two text files \u201c<strong>file3.txt<\/strong>\u201d and \u201c<strong>file4.txt<\/strong>\u201d in a case-insensitive manner. To do so you can follow the steps below.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff -i -y file3.txt file4.txt<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In the image below, you can see that I have displayed the results side-by-side using the <strong>-y <\/strong>option. The command ignores cases and only differentiates the last two lines which are not included in the first file \u201c<strong>file3.txt<\/strong>\u201d.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3143 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15.png\" alt=\"Case insensitive file comparison using diff command in Linux.\" width=\"825\" height=\"170\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15-300x62.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15-1024x211.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15-767x158.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15-1536x317.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15-2048x422.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15-728x150.png 728w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15-100x21.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15-1699x350.png 1699w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-15-788x162.png 788w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_8_Ignoring_White_Spaces_While_Differentiating_Files_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\"><\/span>Example 8: Ignoring White Spaces While Differentiating Files Using the \u201cdiff\u201d Command in Linux<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">You can compare the contents in two files ignoring white spaces using the <strong>diff<\/strong> command in <strong>Linux<\/strong> with the option <strong>-w<\/strong>. In this example, I will compare the two text files \u201c<strong>file7.txt<\/strong>\u201d and \u201c<strong>file8.txt<\/strong>\u201d while ignoring spaces in a line. You can do so by following the steps below.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff -w -s file7.txt file8.txt<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In the image below, at first, I showed the contents of the file using the <strong>cat <\/strong>command. Then I checked if the files become identical ignoring white spaces using the <strong>-s<\/strong> option. The result shows that the files are identical.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3144 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16.png\" alt=\"Ignoring white spaces using diff command in Linux.\" width=\"645\" height=\"158\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16.png 645w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16-300x73.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16-1024x251.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16-767x188.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16-1536x376.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16-2048x502.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16-612x150.png 612w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16-100x24.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16-1429x350.png 1429w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-16-788x193.png 788w\" sizes=\"(max-width: 645px) 100vw, 645px\" \/><\/p>\n<hr \/>\n<p><span style=\"color: #000080; font-size: 18pt;\"><strong>Similar Readings<\/strong><\/span><\/p>\n<ul>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/mv-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201cmv\u201d Command in Linux [8 Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/cp-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201ccp\u201d Command in Linux [6 Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/rm-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201crm\u201d Command in Linux [7 Practical Examples]<\/a><\/strong><\/li>\n<\/ul>\n<hr \/>\n<h3><span class=\"ez-toc-section\" id=\"Example_9_Ignoring_Blank_Lines_While_Differentiating_Files_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\"><\/span>Example 9: Ignoring Blank Lines While Differentiating Files Using the \u201cdiff\u201d Command in Linux<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">You can compare the contents in two files ignoring blank lines using the <strong>diff<\/strong> command in <strong>Linux<\/strong> with the option <strong>-B<\/strong>. In this example, I will compare the two text files \u201c<strong>file9.txt<\/strong>\u201d and \u201c<strong>file10.txt<\/strong>\u201d while they have blank lines. You can do so by following the steps below.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff -B -s file9.txt file10.txt<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In the image below, at first, I showed the contents of the file using the <strong>cat <\/strong>command. Then I checked if the files became identical ignoring blank lines using the <strong>-s<\/strong> option. The result shows that the files are identical.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3145 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17.png\" alt=\"Ignoring blank lines using diff command in Linux.\" width=\"648\" height=\"392\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17.png 648w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17-300x181.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17-1024x619.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17-767x464.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17-1536x929.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17-2048x1239.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17-248x150.png 248w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17-100x60.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17-579x350.png 579w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-17-788x476.png 788w\" sizes=\"(max-width: 648px) 100vw, 648px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_10_Comparing_Two_Directories_Using_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\"><\/span>Example 10: Comparing Two Directories Using the \u201cdiff\u201d Command in Linux<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Using the <strong>diff<\/strong> command in <strong>Linux <\/strong>you can display differences between the contents in two directories. The command prints out the unique files and folders in each directory. In this example, I will differentiate two text directories: \u201c<strong>Desktop<\/strong>\u201d and \u201c<strong>Documents<\/strong>\u201d. To do so you can follow the steps below.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff Desktop Documents<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In the image below, at first, I showed the contents of the directories using the <strong>ls <\/strong>command. Then I displayed the different contents available in each directory.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3091 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11.png\" alt=\"Comparing directory contents using diff command in Linux.\" width=\"571\" height=\"344\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11.png 571w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11-300x181.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11-1024x617.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11-767x462.png 767w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11-1536x925.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11-2048x1234.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11-249x150.png 249w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11-100x60.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11-581x350.png 581w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-11-788x474.png 788w\" sizes=\"(max-width: 571px) 100vw, 571px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_11_Redirecting_Output_of_the_%E2%80%9Cdiff%E2%80%9D_Command_in_Linux\"><\/span>Example 11: Redirecting Output of the \u201cdiff\u201d Command in Linux<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Using the <strong>diff<\/strong> command in <strong>Linux <\/strong>you will be able to write the command output in a desired file. For this, you will have to apply the <strong>Redirection (&gt;)<\/strong> feature in <strong>Linux<\/strong>. In this example, I will redirect the differences between the two text directories: \u201c<strong>Desktop<\/strong>\u201d and \u201c<strong>Documents<\/strong>\u201d in a file called \u201c<strong>diff.txt<\/strong>\u201d. To do so you can follow the steps below.<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p>\u278a At first open the <strong>Ubuntu Terminal<\/strong>.<\/p>\n<p>\u278b Type the following command in the command prompt:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">diff Desktop Documents &gt; diff.txt<\/code><\/pre>\n<p>\u278c Now, press the <strong>ENTER<\/strong> button.<\/p>\n<p><span style=\"color: #800080;\"><strong>Output &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">In the image below, at first, I showed the contents of the directories using the <strong>ls <\/strong>command. Then I redirected the output in the \u201c<strong>diff.txt<\/strong>\u201d file. You can see the results redirected to the \u201c<strong>diff.txt<\/strong>\u201d file using the <strong>cat<\/strong> command.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3092 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12.png\" alt=\"Redirecting output of the using diff command to a file.\" width=\"700\" height=\"235\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12-300x101.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12-1024x344.png 1024w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12-766x257.png 766w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12-1536x516.png 1536w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12-2048x688.png 2048w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12-447x150.png 447w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12-100x34.png 100w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12-1043x350.png 1043w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-command-in-linux-12-788x264.png 788w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In this article, I illustrated the common uses of the <strong>diff<\/strong> command in <strong>Linux<\/strong>. You need to develop an understanding of the <strong>symbols<\/strong> and <strong>instructions<\/strong> to use this command. I hope these practical examples will help you compare files from the <strong>command line<\/strong> and aid your experience with <strong>Linux<\/strong>.<\/p>\n<hr \/>\n<p><span style=\"color: #000080; font-size: 18pt;\"><strong>Similar Readings<\/strong><\/span><\/p>\n<ul>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/touch-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201ctouch\u201d Command in Linux [8 Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/mkdir-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201cmkdir\u201d Command in Linux [6+ Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/locate-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201clocate\u201d Command in Linux [7 Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/find-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201cfind\u201d Command in Linux [10+ Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/chmod-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The \u201cchmod\u201d Command in Linux [6 Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/chown-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">The &#8220;chown&#8221; Command in Linux [8 Practical Examples]<\/a><\/strong><\/li>\n<\/ul>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-center kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;center&quot;,&quot;id&quot;:&quot;3054&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;The \u201cdiff\u201d Command in Linux [11 Practical Examples]&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            <span class=\"kksr-muted\">Rate this post<\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>The diff command in Linux is a utility tool that allows you to compare files from the command line. It &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"The \u201cdiff\u201d Command in Linux [11 Practical Examples]\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/#more-3054\" aria-label=\"Read more about The \u201cdiff\u201d Command in Linux [11 Practical Examples]\">Read more<\/a><\/p>\n","protected":false},"author":314896,"featured_media":3094,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[55],"class_list":["post-3054","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-commands","tag-file-management-commands","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The \u201cdiff\u201d Command in Linux [11 Practical Examples] - LinuxSimply<\/title>\n<meta name=\"description\" content=\"The diff command in Linux allows you to compare the contents within files and folders. It also provides instructions to make files similar.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The \u201cdiff\u201d Command in Linux [11 Practical Examples] - LinuxSimply\" \/>\n<meta property=\"og:description\" content=\"The diff command in Linux allows you to compare the contents within files and folders. It also provides instructions to make files similar.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/diff-command-in-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxSimply\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/profile.php?id=100005994046772&amp;mibextid=ZbWKwL\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-05T11:26:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-30T05:38:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-commad-in-linux.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Anonnya Ghosh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anonnya Ghosh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/\"},\"author\":{\"name\":\"Anonnya Ghosh\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/b53a69b64755f081b3c5951d72ba9c7c\"},\"headline\":\"The \u201cdiff\u201d Command in Linux [11 Practical Examples]\",\"datePublished\":\"2023-01-05T11:26:08+00:00\",\"dateModified\":\"2023-08-30T05:38:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/\"},\"wordCount\":2246,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/diff-commad-in-linux.png\",\"keywords\":[\"file management commands\"],\"articleSection\":[\"Linux Commands\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/\",\"name\":\"The \u201cdiff\u201d Command in Linux [11 Practical Examples] - LinuxSimply\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/diff-commad-in-linux.png\",\"datePublished\":\"2023-01-05T11:26:08+00:00\",\"dateModified\":\"2023-08-30T05:38:38+00:00\",\"description\":\"The diff command in Linux allows you to compare the contents within files and folders. It also provides instructions to make files similar.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/diff-commad-in-linux.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/diff-commad-in-linux.png\",\"width\":400,\"height\":400,\"caption\":\"diff commad in linux\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/diff-command-in-linux\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The \u201cdiff\u201d Command in Linux [11 Practical Examples]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"name\":\"LinuxSimply\",\"description\":\"All About Linux\",\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/linuxsimply.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\",\"name\":\"LinuxSimply\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"width\":355,\"height\":48,\"caption\":\"LinuxSimply\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/b53a69b64755f081b3c5951d72ba9c7c\",\"name\":\"Anonnya Ghosh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Anonnya-Ghosh-II-96x96.png\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Anonnya-Ghosh-II-96x96.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Anonnya-Ghosh-II-96x96.png\",\"caption\":\"Anonnya Ghosh\"},\"description\":\"Hello there! I am Anonnya Ghosh, a Computer Science and Engineering graduate from Ahsanullah University of Science and Technology (AUST). Currently, I am working as a Linux Content Developer Executive at SOFTEKO. The strong bond between Linux and cybersecurity drives me to explore this world of open-source architecture. I aspire to learn new things further and contribute to the field of CS with my experience. Read Full Bio\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/profile.php?id=100005994046772&mibextid=ZbWKwL\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/anonnya-ghosh-6a934b211\"],\"url\":\"https:\\\/\\\/linuxsimply.com\\\/author\\\/anonya\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The \u201cdiff\u201d Command in Linux [11 Practical Examples] - LinuxSimply","description":"The diff command in Linux allows you to compare the contents within files and folders. It also provides instructions to make files similar.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/linuxsimply.com\/diff-command-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"The \u201cdiff\u201d Command in Linux [11 Practical Examples] - LinuxSimply","og_description":"The diff command in Linux allows you to compare the contents within files and folders. It also provides instructions to make files similar.","og_url":"https:\/\/linuxsimply.com\/diff-command-in-linux\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/profile.php?id=100005994046772&mibextid=ZbWKwL","article_published_time":"2023-01-05T11:26:08+00:00","article_modified_time":"2023-08-30T05:38:38+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-commad-in-linux.png","type":"image\/png"}],"author":"Anonnya Ghosh","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Anonnya Ghosh","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/diff-command-in-linux\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/diff-command-in-linux\/"},"author":{"name":"Anonnya Ghosh","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/b53a69b64755f081b3c5951d72ba9c7c"},"headline":"The \u201cdiff\u201d Command in Linux [11 Practical Examples]","datePublished":"2023-01-05T11:26:08+00:00","dateModified":"2023-08-30T05:38:38+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/diff-command-in-linux\/"},"wordCount":2246,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/diff-command-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-commad-in-linux.png","keywords":["file management commands"],"articleSection":["Linux Commands"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/diff-command-in-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/diff-command-in-linux\/","url":"https:\/\/linuxsimply.com\/diff-command-in-linux\/","name":"The \u201cdiff\u201d Command in Linux [11 Practical Examples] - LinuxSimply","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/diff-command-in-linux\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/diff-command-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-commad-in-linux.png","datePublished":"2023-01-05T11:26:08+00:00","dateModified":"2023-08-30T05:38:38+00:00","description":"The diff command in Linux allows you to compare the contents within files and folders. It also provides instructions to make files similar.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/diff-command-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/diff-command-in-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/diff-command-in-linux\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-commad-in-linux.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/01\/diff-commad-in-linux.png","width":400,"height":400,"caption":"diff commad in linux"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/diff-command-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxsimply.com\/"},{"@type":"ListItem","position":2,"name":"The \u201cdiff\u201d Command in Linux [11 Practical Examples]"}]},{"@type":"WebSite","@id":"https:\/\/linuxsimply.com\/#website","url":"https:\/\/linuxsimply.com\/","name":"LinuxSimply","description":"All About Linux","publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxsimply.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxsimply.com\/#organization","name":"LinuxSimply","url":"https:\/\/linuxsimply.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","width":355,"height":48,"caption":"LinuxSimply"},"image":{"@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/b53a69b64755f081b3c5951d72ba9c7c","name":"Anonnya Ghosh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Anonnya-Ghosh-II-96x96.png","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Anonnya-Ghosh-II-96x96.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Anonnya-Ghosh-II-96x96.png","caption":"Anonnya Ghosh"},"description":"Hello there! I am Anonnya Ghosh, a Computer Science and Engineering graduate from Ahsanullah University of Science and Technology (AUST). Currently, I am working as a Linux Content Developer Executive at SOFTEKO. The strong bond between Linux and cybersecurity drives me to explore this world of open-source architecture. I aspire to learn new things further and contribute to the field of CS with my experience. Read Full Bio","sameAs":["https:\/\/www.facebook.com\/profile.php?id=100005994046772&mibextid=ZbWKwL","https:\/\/www.linkedin.com\/in\/anonnya-ghosh-6a934b211"],"url":"https:\/\/linuxsimply.com\/author\/anonya\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/3054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/users\/314896"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/comments?post=3054"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/3054\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/3094"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=3054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=3054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=3054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}