LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 01-15-2014, 10:04 AM   #1
chris_carr
Member
 
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:

"#!/bin/bash
#This is a script to find duplicate files using Md5sum

SRC_DIR=/directory/home/user/NOTES/
RESULT_FILE=/directory/home/home/checksum_result.txt
FAILURE=/directory/home/user/checksum_fail.txt
SUCCESS=/directory/home/user/checksum_win.txt
cd $SRC_DIR
find ./ -type f -exec md5sum {} \; > /directory/home/user/checksum.txt
md5sum -c < /directory/home/user/checksum.txt > $RESULT_FILE
if [ "$file1" != "$file2" ];

then"

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
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,879
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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.
 
  


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
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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:44 AM.

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
Open Source Consulting | Domain Registration