?
Solved

Linux md5sum script

Posted on 2012-03-13
4
Medium Priority
?
376 Views
Last Modified: 2012-03-21
Hello,

I would like a script to achieve the following:

(Example locations only)
/tmp/sample-files contains the following files: md5-1, md5-2, md5-3 etc

1. Run the script against the target directory /tmp/sample-files
2. Create a file that contains a list of the files to be checksummed (md5-sum-src)
3. Run the md5sum command against the above file and output the results to another file (md5-sum-results).


Thanks,

Phil
0
Comment
Question by:PhilMacavity
  • 2
  • 2
4 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 37713908
Why do you need an intermediate file?

Just run

md5sum /tmp/sample-files/* > md5-sum-results

That's all.

wmp
0
 
LVL 1

Author Comment

by:PhilMacavity
ID: 37713982
Hi Wmp,

Thaks for the comment.

md5sum /tmp/sample-files/* > md5-sum-results would work for my initial plans . Instead of, having to run the md5sum command multiple times against the target directories, i was planning to run it once against a src file containing a list of the files to be checksummed.

Cheers,

Phil.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 750 total points
ID: 37714023
To pull a checksum you will have to access the files (and thus their directories) nonetheless, so what should the file be good for?

Do you expect that the contents of the directories change regularly?

Ok, using an intermediate file would avoid checking new files (which might be intended), but would also try to checksum deleted files, which will lead to errors.

And you don't have to run the md5sum command multiple times:

md5sum /tmp/sample-files-1/* /tmp/sample-files-2/* /tmp/sample-files-3/* > md5-sum-results

Anyway:

find  /tmp/sample-files -type f > md5-sum-src

while read file; do
  md5sum $file >> md5-sum-results
   done < md5-sum-src

wmp
0
 
LVL 1

Author Comment

by:PhilMacavity
ID: 37746424
Hi wmp,

Thanks for the suggestions. These should be enough for me to achieve what i need.

Cheers,

Phil
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question