Fedora Linux Support Community & Resources Center
  #1  
Old 29th April 2009, 04:06 AM
michael12345 Offline
Registered User
 
Join Date: Nov 2008
Posts: 186
parse md5 in bash

I'm working on a script and need to parse the hash from a file create by this command:
md5sum somefile >> md5_log

The reason I need to hash is the contents of md5_log does not identify the correct file...sorta.
i.e.

hashnumbers /dev/sda

where /dev/sda is the original file hashed.

I need to compare the hash to the file after it's been moved, thus /dev/sda is incorrect, so md5sum -c will not compare the correct file.

Any input on how I can do this? Parse to white space or copy the hash and replace /dev/sda?
I need a new log file for the comparison.

awk '{print $1}' md5log would seem to have promise if I could concatenate my variable that states the new file to the end of the awk output

finding some good info in here : http://forums.fedoraforum.org/showthread.php?t=220435 but any input is always appreciated.

Last edited by michael12345; 29th April 2009 at 04:43 AM.
Reply With Quote
  #2  
Old 29th April 2009, 05:20 AM
daverj Offline
Registered User
 
Join Date: Jan 2006
Location: Denver, CO USA
Posts: 670
provide some sample output. Its much easier to hack a script if we know what your expected output looks like.
Reply With Quote
  #3  
Old 29th April 2009, 05:27 AM
michael12345 Offline
Registered User
 
Join Date: Nov 2008
Posts: 186
#md5sum /dev/sdb >> /folder/md5sum_file

# cat md5sum_file
80c77138c2f5df8eea2cdbd7832c8bdb /dev/sdb

dd if=/dev/sdb of=/folder/copied_drive.dd

Trying to automate the comparison of copied_drive.dd to md5sum_file

md5sum -c md5sum_file will read /dev/sdb and try to scan that device when I want it to actually scan copied_drive.dd5

Last edited by michael12345; 29th April 2009 at 05:43 AM.
Reply With Quote
  #4  
Old 29th April 2009, 06:07 AM
michael12345 Offline
Registered User
 
Join Date: Nov 2008
Posts: 186
got it I think. Thanks. I'll post an update if it's certain.
Reply With Quote
  #5  
Old 29th April 2009, 07:29 AM
cazo Online
Registered User
 
Join Date: Sep 2005
Location: Redneck Riviera
Posts: 333
md5sum's -c option works if you use the relative path of the filename(s) instead of the absolute path. I use this same method to verify files burned to CD/DVD before deleting them.

For example, if the files are in
Code:
~/Download/
I first
Code:
pushd ~/Download
(or 'cd ~/Download' will work), then
Code:
md5sum source/* >> source.md5
. After burning 'source' to the CD/DVD, I use
Code:
pushd /media/CD001
md5sum -c ~/Download/source.md5
This will print 'OK' for each file found & verified. Missing and/or changed files will report an error.

I normally use 'pushd' and 'popd' in scripts (as well as the shell) instead of 'cd', since it saves the previous directories on the 'dir stack' and makes getting back easier (for me). Also, the variable $OLDPWD is handy (refers to the previous directory).
Reply With Quote
Reply

Tags
bash, md5, parse

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
parse a log file Wiles Programming & Packaging 1 31st August 2007 04:42 AM
Apache parse some php and not all amaj1407 Servers & Networking 3 6th July 2007 12:18 PM
How to parse a log file Goooofy Using Fedora 1 27th September 2005 06:36 PM


Current GMT-time: 14:17 (Friday, 24-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat