To compare directories in a Unix-like operating system, you can use the diff command with the -r option, which allows for recursive comparison of subdirectories. Here’s how to do it:
Basic Command:
diff -r dir1 dir2
Explanation:
diff: The command used to compare files and directories.-r: This option tellsdiffto recursively compare any subdirectories found withindir1anddir2.dir1anddir2: These are the paths to the directories you want to compare.
Example:
If you have two directories named dir1 and dir2, you would run:
diff -r dir1 dir2
Output:
The output will show:
- Files that are unique to each directory.
- Differences in files that exist in both directories.
Additional Options:
-
-q: Use this option to suppress detailed output and only report whether the directories differ.diff -rq dir1 dir2 -
--brief: Similar to-q, it reports only whether files differ or are unique.
If you have any further questions or need more examples, feel free to ask!
