Announcement

Collapse
No announcement yet.

BASH: check md5sums of two files and compare

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    BASH: check md5sums of two files and compare

    Hello.

    Here is the situation:
    I am copying large files from one drive to another and I want make sure that the copies are exact duplicates of the original. So to do that, I can check the hashes of the original file and compare it to the hashes of duplicate. However, when copying huge files, checking the file hashes of the first file can take a while depending on the computer's speed. So I have to wait for it to finish, then check the hashes of the second file again. This also means that I have to type two separate commands. I wish there is a feature in md5sum that checks the hashes of two (or more) files and compare them after checking, but I don't think that feature exists yet.

    The question:
    What command do I have to use (using pipes) to merge both commands and compare them in one line?

    example: $ compare (md5sum /home/myfile.iso) (md5sum /media/hd2/myfile.iso)
    or $ compare `md5sum /home/myfile.iso` `md5sum /media/hd2/myfile.iso`

    Note: The "compare" command in my example does not exist. I only used it to help me while explaining.


    Thank you!


    ps. I am not good in bash yet, but I want to (and trying to) learn!

    #2
    Re: BASH: check md5sums of two files and compare

    Well, im newb to linux, but i think using the command recursively will solve your problem. Put the two files that youw ant to compare in teh same folder, and use md5sum , pass it the path of the folder, (NOT the path of the file) and add a
    Code:
     -r
    to the end. That should check both files in one command. However, im not sure how legible the output will be =)

    im unsure of syntax, but your usage should be along teh lines of

    Code:
     md5sum /path/to/folder/with/files -r

    hope this helps. If it doesnt, dont flame
    im newb too :P

    Comment


      #3
      Re: BASH: check md5sums of two files and compare

      http://kubuntuforums.net/forums/inde...51335#msg51335

      Comment


        #4
        Re: BASH: check md5sums of two files and compare

        Thanks for the input guys! I'm gonna give it a try.

        Comment

        Working...
        X