# How to compare files in 2 directories?

**URL:** <https://community.unix.com/t/how-to-compare-files-in-2-directories/274047>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [September 24, 2010, 10:50am UTC](https://community.unix.com/t/how-to-compare-files-in-2-directories/274047 "2010-09-24T10:50:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andre\_2008](https://community.unix.com/letter_avatar/andre_2008/32/5_5575768a8748004e209b776fc1b2916d.png) [@Andre\_2008](https://community.unix.com/u/Andre_2008)\
**Post date:** [September 24, 2010, 10:50am UTC](https://community.unix.com/t/how-to-compare-files-in-2-directories/274047/1 "2010-09-24T10:50:45Z")

</div>

Hi,

I want to compare the content of 2 directories and list down both the duplicate and unique files from each directory. Tried to use diff but but not able to achieve the result.

For example,

DirA  
FileX  
FileY  
FileZ

DirB  
FileY

The desired outcome is  
Duplication: FileY  
Unique: FileX FileZ

Please help. Thanks

---

<div class="post-metadata">

**Author:** ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)\
**Post date:** [September 24, 2010, 11:02am UTC](https://community.unix.com/t/how-to-compare-files-in-2-directories/274047/2 "2010-09-24T11:02:39Z")

</div>

Have you tried diff command yet?
