Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-15-2014, 10:04 AM   #1
Registered: Oct 2011
Location: Houston Tx
Distribution: RHEL 6
Posts: 57

Rep: Reputation: 0
MD5 sum check

Hey guys,

I have had this question answered before on this site, but like a dummy I did not save my script.

I'm trying to write a bash script that points to a file server to check for duplicate files. I have done some googling, but I see to be stuck on an if statement.

here is what I have so far:

#This is a script to find duplicate files using Md5sum

find ./ -type f -exec md5sum {} \; > /directory/home/user/checksum.txt
md5sum -c < /directory/home/user/checksum.txt > $RESULT_FILE
if [ "$file1" != "$file2" ];


This is where I get stuck.

" if [ "$file1" != "$file2" ]; "

I'm not entirely sure if the IF statement is correct. I want it to compare the checksum.txt file to the RESULTS file, then print the duplicates into a checksum_fail.txt file.
Old 01-15-2014, 10:08 AM   #2
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,458
Blog Entries: 12

Rep: Reputation: 1905Reputation: 1905Reputation: 1905Reputation: 1905Reputation: 1905Reputation: 1905Reputation: 1905Reputation: 1905Reputation: 1905Reputation: 1905Reputation: 1905
For starters, you need to setup the variables for $FILE1 and $FILE2; or show that part of the script, because right now those variables do not exist at the point which you are comparing them.

Please place your code within [code] tags.
Old 01-15-2014, 11:39 AM   #3
Senior Member
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491
There is a logical error here. An md5sum is only accurate if two files have the same size. Two md5sums can be the same for two files of different size.


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
MD5 Sum Verification Procedure Mokoyombi Linux - Newbie 4 07-03-2012 09:19 PM
MD5 sum Pedroski Linux - Software 4 12-08-2009 02:17 PM
How to check the MD5 sum Gins Linux - General 12 05-21-2006 11:32 AM
md5 sum incorrect barrythai Fedora 3 10-10-2005 11:59 AM
knoppix and Md5 sum ??? bigjohn Linux - Newbie 10 09-27-2003 11:16 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:30 PM.

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