• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How To Compare Two Folders And Find Missing Files In Linux

How To Compare Two Folders And Find Missing Files In Linux

By Sourabh / April 4, 2024 Category: How To, Ubuntu

Here is how to compare two folders and find missing files Linux Ubuntu. You can use the diff command to compare directories in Linux command line.

diff Command in Linux

The Linux diff command is a powerful and useful utility for comparing two files. It can be used to compare text files, directories, and even binary files. It is a command-line tool that can be used to compare two files and to report differences between them.

It is a command-line tool that can be used to compare two files and to report differences between them. It can be used to compare text files, directories, and even binary files. It can be used to determine the differences between two files, such as the number of lines, the number of characters, or the content of each line. It can also be used to compare two directories by looking at the differences in the files contained within each directory.

When comparing two files, the diff command will display each line of the files that are different. It will also report the line numbers of the differences and the number of differences between the two files. The diff command can also be used to compare binary files by looking at the differences in the bytes of each file.

Using diff Command in Linux

The diff command compares corresponding files in both directories, in alphabetical order; this comparison is not recursive unless the --recursive' (-r’) option is given. Note that the `diff’ command never compares the actual contents of a directory as if it were a file.

To use the diff command, simply use the following syntax:

diff -qr Directory-1 Directory-2

For example we will compare two directories named FLDR1 and FLDR2 to find the differences. We will use the command option -q which will report only when the differences are found.

diff -q FLDR1 FLDR2

NOTE: The command argument -q won’t look for the files inside the subdirectory. To see the differences inside the subdirectory, use the -r command option:

diff -qr FLDR1 FLDR2

Similarly if you want to know the similar files inside the directory use the -s command option.

In the commands explained above, these arguments are used:

  1. -q' or–brief’ – It is sued to report only whether the files differ, not the details of the differences.
  2. -r' or–recursive’ – It is used to recursively compare any subdirectories found when comparing directories.
  3. -s' or–report-identical-files’ – It is used to see the list of similar files. It will report when two files are the same.

If only one file exists, `diff’ normally does not show its contents; it merely reports that one file exists but the other does not.

The diff command can be used for a variety of purposes, such as to compare source code files, to compare configuration files, to find differences between two versions of a file, or to find differences between two directories.

Primary Sidebar

Latest Posts

Delete Directory And Contents Recursively Without Prompt On Linux

Check User Login History In Ubuntu Linux Command Line

Use Locate Command To Find File In Linux Terminal By Name

How To Change Terminal Color In Ubuntu Command Line

How To Run Fsck Manually In Linux To Fix Unexpected Inconsistency

How To Fix Broken Packages On Ubuntu From Terminal

Re Execute The Previous Command In Linux Ubuntu Command Line

How Much RAM Is Needed For Ubuntu PC

How To Find Large Files And Directories In Linux Command Line

How To Use Clear Command History In Linux Terminal

© 2026 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap