Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

find(ing) md5sum(ming) awk-formatting in a one liner ...

36 views
Skip to first unread message

qwert...@syberianoutpost.ru

unread,
Nov 3, 2012, 1:02:38 PM11/3/12
to
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

Jon LaBadie

unread,
Nov 3, 2012, 6:31:23 PM11/3/12
to
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"/'

0 new messages