Solved

Linux md5sum script

Posted on 2012-03-13
4
328 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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
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.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now