LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-27-2014, 08:35 AM   #1
azheruddin
Member
 
Registered: Dec 2011
Posts: 83
Blog Entries: 1

Rep: Reputation: Disabled
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.
 
Old 08-27-2014, 08:38 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,106

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
what have you tried so far and where are you stuck.

i think md5sum in a for loop would be adaquate.
 
Old 08-27-2014, 08:47 AM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,185

Rep: Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586Reputation: 1586
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
 
Old 08-27-2014, 09:09 AM   #4
azheruddin
Member
 
Registered: Dec 2011
Posts: 83
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Thumbs up

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

Thanks Again techies.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to compare a list of files in two directories: compare content and print size Batistuta_g_2000 Linux - Newbie 9 03-24-2013 07:05 AM
Shell Script to compare folders,Sub-Folders and Sub-Sub-Folders unix_72427 Programming 8 08-08-2012 02:51 PM
How do i turn a bunch of files/folders into a .deb? linus72 Debian 1 01-26-2010 05:51 PM
can someone compare this 2 folders ..HELP bladez99 Linux - Newbie 4 08-10-2009 12:18 PM
compare two folders bluenectar Linux - Newbie 10 08-04-2005 11:23 PM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration