Okay so I have a somewhat large file (~200 meg) that I need to regularly hash to see if it has changed.

The catch is that there are two small fields in this file which must be ignored as they may change. Each of these fields has a known and fixed offset and size.

I have got this working using three cmp commands, however because this needs to be done regularly I'd like to do it in the most efficient way possible. Also it is problematic to have to store a backup copy of the file, and would be much better to just store a hash to compare against.

So far the closest I've got is something like this:

dd read from start of file up to offset of first field | md5sum

dd read from end of first field up to start of second field | md5sum

dd read from end of second field to end of file | md5sum

Is there any way I can redirect the output of all three of those dd commands into one md5sum instance so I can get a single hash out? I'd rather not have the three dd commands write into a temp file and then hash that as it would be a lot of I/O. I'd like to do it as efficiently as possible.

Any suggestions would be greatly appreciated!!

  • 1
    The policy here is to leave the question up, so that it may help future readers. Please don't ask for deletion. Don't forget to upvote and accept any answer that might have helped you solve your problem.
    – rahmu
    Commented Apr 1, 2013 at 10:06

2 Answers 2


If you really want to hash the data use a subshell:

( dd_1 ; dd_2 ; dd_3 ) | md5sum

Otherwise I would suggest using Hojat's answer - hash it piecewise and do something with those "subhashes".


You can cat the three md5 sum's to a file and after that make another md5 on that file, any changes to one of those hashes results in mismatch at the final text file hash.

concatenate md5(1) AND md5(2) AND md5(3) to final file --> md5(final_file)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .