[clug] using 'dd' in a pipeline
paulway at mabula.net
Mon Nov 24 04:02:07 MST 2014
-----BEGIN PGP SIGNED MESSAGE-----
On 24/11/14 13:56, steve jenkin wrote:
> I’ve been looking at deliberate MD5 collisions and went to write a simple
> script based on ‘dd’, only to fall flat on my face - detecting ‘end of
> file’ from STDIN.
> ‘dd’ doesn’t consider EOF as an error and returns “success”.
Man, this is so reminding me of the classic X-Y problem:
(pasting the specific reference for the people to lazy to read it :-) )
RikusW> Say I have a filename in $1 how would I get its size ?
erUSUL> du $file
erUSUL> du "$file" even
RikusW> havent thought of that ... :)
greycat> Literal answers to bad questions can be dangerous.
greycat> WHY do you want its size? What is the POINT?
RikusW> `du $1` maybe ?
RikusW> Want to write a script to dd 512k sections out and md5sum it...
erUSUL> RikusW: huh? you want to do something with the size later?
greycat> you want to WHAT?
RikusW> dd doesn't return 1 when the end is reached...
greycat> ... why wouldn't you take a SINGLE md5 of the whole thing?
RikusW> I have a corrupt 500mb file....
RikusW> and a slow connection
Word-wise comparison of two sections should be relatively quick in Your
Favourite Programming Language (i.e. not bash, which gets all confused with
binary data). I don't see optimising for speed as requiring lots of
complicated code. And md5sums have to read the entire block, whereas a
direct comparison will stop at the first word that fails to match.
But I'm still guessing as to what your objective is, or where you're going.
What data is being thrown at you? How will you know if it's correct or
not? What methods have you tried that have failed?
Hope this helps,
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
-----END PGP SIGNATURE-----
More information about the linux