MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
July
Sun Mon Tue Wed Thu Fri Sat
8
       
2012
Months
Jul


Sun, Jul 08, 2012 9:14 pm

Comparing Two Directories with Diff

If you need to compare two directories to determine which files are in one directory, but not another, on a Unix, Linux, or Mac OS X system, you can use the diff command. E.g., suppose the directories are named dir1 and dir2; they can be compared with diff dir1 dir2
$ diff dir1 dir2
Only in dir2: index.html
Common subdirectories dir1/temp and dir2/temp
Only in dir2: a.png
Only in dir2: b.png
Only in dir1: 123.png
Only in dir1: 456.png

If you wish to see only the differences and not common directories and subdirectories, you can use diff dir1 dir2 | grep "Only". To perform the comparision recursively through the various subdirectories within the two directories use diff --recursive dir1 dir2.

Reference:

  1. Find files in one directory not in another
    Server Fault

[/os/unix/commands] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo