bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#10355: Add an option to {md5,sha*} to ignore directories


From: Gilles Espinasse
Subject: bug#10355: Add an option to {md5,sha*} to ignore directories
Date: Fri, 23 Dec 2011 18:53:27 +0100

----- Original Message ----- 
From: "Bob Proulx" <address@hidden>
To: "Gilles Espinasse" <address@hidden>; <address@hidden>
Sent: Friday, December 23, 2011 6:17 PM
Subject: Re: bug#10355: Add an option to {md5,sha*} to ignore directories


> severity 10355 wishlist
> tags 10355 + notabug wontfix moreinfo
> thanks
>
> Erik Auerswald wrote:
> > Gilles Espinasse wrote:
> > >I was using a way to check md5sum on a lot of file using
> > >  for myfile in `cat ${ALLFILES}`; do if [ -f /${myfile} ]; then md5sum
> > >/$myfile>>  $ALLFILES}.md5; fi; done
> >...
> > You could use "find $DIR -type f" to list regular files only.
>
Thank for the suggestion.
ALLFILES is indirectly made using find $DIR, but I can't use -type f during
that find.
The primary usage of that list is to create a tar using --files-from and
when a directory is empty, you need to include the directory name directly.

> Yes.  Exactly.  The capability you ask for is already present.
>
> Please try this:
>
>   find . -type f -exec md5sum {} +
>
> Replace '.' above with a directory if you wish it to find files in a
> different directory.
>
> Bob

This does not work too in my case.
I didn't want to calculate md5 for each file found in my chroot.
I care only for a shorter list of files to be include in a tar.

The only change I find is derived from the slow version, but instead of
running md5sum each time, adding true file names to a list that md5sum will
only use at the end:
rm /tmp/ALLFILES*
time (for myfile in ${ALLFILES} | sed -e 's/^dev.*//' -e 's/^sys.*//'); do
if [ -f /${myfile} ]; then echo /$myfile >>/tmp/ALLFILES; fi; done; xargs
md5sum < /tmp/ALLFILES >/tmp/ALLFILES.md5)

real    0m1.967s
user    0m1.368s
sys     0m0.604s

This is approximatly 100% slower than the fast version but does not need
hiding errors (from directory message and program status). That's fast
enought for my need and divide by 5 the time from the first slow version.

Gilles






reply via email to

[Prev in Thread] Current Thread [Next in Thread]