On 11/03/2012 01:02 PM, qwertmon
...@syberianoutpost.ru wrote:
> since md5 check sums include the name of the file, you can find and md5sum
> files a la:
> ~
> find . -type f -printf '%Ts,%As,%Cs,"%M",%n,"%u","%g",%s,%d'
> -exec md5sum -b {} \;
> ~
> the thing is that I am trying to create a csv file so I need to somehow format
> md5sum's output as well, but if I try (and tried I have many things ;-)) to use
> awk's printf for just the md5sum output it creates all some of problems
> apparently related to the bash interpreter and file paths containing spaces for
> the find one liner and separately while just using md5sum
> ~
> you could just go monkey and do things in two runs (which may be faster and
> more portable?), but I would like to test the all-in-one run anyway
> ~
> How do you play with awk's printf to make it print a csv line (after find's
> -printf output)?
> ~
> thanks
> lbrtchx
First, I would add a trailing comma to your printf. Otherwise the depth and
the md5sum would be combined. On my system that yielded output lines that
ended like this:
... 1,d41d8cd98f00b204e9800998ecf8427e *./bar
where everything after the "1," comes from md5sum. I assume you want the
sum as a string (in quotes). I'd use sed to modify the output:
find . -type f -printf '%Ts,%As,%Cs,"%M",%n,"%u","%g",%s,%d,' -exec md5sum -b {} \; |
sed -e 's/,\(.*\) \*\(.*\)$/,"\1","\2"/'