Jump to content
The Dark Mod Forums

Validating lots of checksums in Linux automatically.


lost_soul

Recommended Posts

Let's say I have a remote server with a lot of files on it. They all reside in ONE directory, and this directory also includes an md5sums.txt file that contains checksums for every file in the directory. Let's call this file remotesums.txt.

 

Then I have a local system with SOME of the files which exist on the remote system. It is a small amount, yet still too many to verify by hand. I can write the checksums of these to a file, let's call it localsums.txt.

 

So, every line that is in localsums.txt should ALSO be in remotesums.txt, but remotesums.txt will have lots of lines that do not exist in localsums.txt because I only have some of the files and thus some of the checksums. They may also be in a different order. How do I verify this that what is in localsums.txt is correct?

 

I was thinking of something like:

 

for $line_of_text in localsums.txt

do grep $line_of_text remotesums.txt > results.txt

 

This (with correct syntax) should produce a file called results.txt which should match localsums.txt if all file checksums match up, right? Is there a better way to do this? You could also use a line counting utility to make sure all of them were found in remotesums.txt.

Edited by lost_soul

--- War does not decide who is right, war decides who is left.

Link to comment
Share on other sites

Use sort and diff:

 

md5sum -b * | sort >remotesum

 

md5sum -b * | sort >localsum

 

diff -u localsum remotesum

 

Also helpful might be md5sums "-c" option.

  • Like 1

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

... and another way. http://unixhelp.ed.a...GI/man-cgi?comm

 

suppress all lines that are unique to remotesums.txt, dump the rest to a file called check.txt, and then run

diff check.txt localsums.txt

 

EDIT: This got me the results I was looking for. The only additional step I had to do was use sed to remove tabs that were inserted when I ran comm on the input text files. I also had to run sort on the text files before passing them to comm.

Edited by lost_soul
  • Like 1

--- War does not decide who is right, war decides who is left.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 2 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 5 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
×
×
  • Create New...