# How to compare two files in ansible ..

**URL:** <https://forum.ansible.com/t/how-to-compare-two-files-in-ansible/22577>\
**Category:** Ansible Project\
**Created:** [September 17, 2016, 10:31am UTC](https://forum.ansible.com/t/how-to-compare-two-files-in-ansible/22577 "2016-09-17T10:31:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shameer1687](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@shameer1687](https://forum.ansible.com/u/shameer1687)\
**Post date:** [September 17, 2016, 10:31am UTC](https://forum.ansible.com/t/how-to-compare-two-files-in-ansible/22577/1 "2016-09-17T10:31:06Z")

</div>

Friends ,

Please help me on this

How to compare two DIRECOTY files in ansible … i have one file called text.sh it is in one directory and i have two files in other diretory how to compare these two file , if no difference need to print no difference , else it need to print file has differen

FIRST DIRECTOYR

CAT SAM.TXT  
RAMESH:GANESH

SECOND DIRECTOY HAS TWO FILES  
ls -l  
ram.txt  
ganessh.txt

cat ram.txt  
RAMESH:GANESH

cat ganessh.txt  
sankar:ganesh

Now we have to compare the two folder , first folder alwasy contain one single file ,but second folder contact any number of files, Need to compare and if difference found we need to print there is difference in file.

Thanks  
Shameer
