To compare two directories and identify any discrepancies between their contents, you can use the diff command in the terminal. Here’s how to do it:
-
Open your terminal.
-
Use the following command to compare the two directories:
diff -r /path/to/dir1 /path/to/dir2Replace
/path/to/dir1and/path/to/dir2with the actual paths of the directories you want to compare.
Example
If you want to compare dir1 and dir2 located in /home/labex/project, you would run:
diff -r /home/labex/project/dir1 /home/labex/project/dir2
Output
The output will list the differences, including files that are only in one directory or files that differ between the two directories. For example:
Only in /home/labex/project/dir1: fileA.txt
Only in /home/labex/project/dir2: fileB.txt
Files /home/labex/project/dir1/fileC.txt and /home/labex/project/dir2/fileC.txt differ
This output indicates which files are unique to each directory and which files have differences.
