LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   compare bunch of files, one on one, between two Folders (https://www.linuxquestions.org/questions/linux-newbie-8/compare-bunch-of-files-one-on-one-between-two-folders-4175516519/)

azheruddin 08-27-2014 08:35 AM

compare bunch of files, one on one, between two Folders
 
Hi,

Wanted to write one shell script to compare bunch of files, one on one, between two Folders and if the difference found only filename should be written to the log file.

Say for e.g
Folder A Folder B Log File
File A File A File A
File B File B
File C File C File C
: :
: :
File N File N

Please assist.

schneidz 08-27-2014 08:38 AM

what have you tried so far and where are you stuck.

i think md5sum in a for loop would be adaquate.

szboardstretcher 08-27-2014 08:47 AM

You don't need a script, you need just a command:

Code:

diff -rq dir1/ dir2/
My test and output:
Code:

[root@dev /]# mkdir dir1
[root@dev /]# mkdir dir2
[root@dev /]# touch dir1/this
[root@dev /]# touch dir1/this1
[root@dev /]# touch dir1/this2
[root@dev /]# touch dir2/this
[root@dev /]# touch dir2/this1
[root@dev /]# touch dir2/this2
[root@dev /]# echo BLAH > dir2/this2
[root@dev /]# diff -rq dir1/ dir2/

Files dir1/this2 and dir2/this2 differ


azheruddin 08-27-2014 09:09 AM

Thanks a lot, will try to map in my actual requirement then will let you know for any issue.

Thanks Again techies.


All times are GMT -5. The time now is 02:23 PM.