[UNCLASSIFIED]RE: [clug] What's the fastest way of deleting files
?
Martin Pool
mbp at sourcefrog.net
Thu May 12 06:30:14 GMT 2005
On 12 May 2005, Antti.Roppola at brs.gov.au wrote:
> Stephen Jenkin wrote:
>
> > find ...|xargs /bin/rm --- should _always_ be quicker that -exec rm
> > (Invokes rm least number of times, versus once per file)
>
> I usually do this, but spaces in file names have been annoying me for
> a long while when doing this to other people's data. but never enough
> to fix it properly. However I just RTFM'ed and:
>
> find . -print0 |xargs -0 rm
This will fail on subdirectories.
I'd be surprised if it were much faster than 'rm -rf' anyhow.
Mass deletion is an interesting benchmark for filesystems, and as I
recall one that reiserfs does not handle well.
A nice point of find when using it for deletion is the -depth option,
which causes it to work depth-first. For example to delete any
directories, or any directories containing only directories:
find . -empty -type d -exec rmdir -v {} \;
> Murphy says that now that I have worked around this annoyance, people
> will start using some other reserved character in their file names
> Probably single quotes as apostrophes.
They can't use \0 though, so -print0 will always work, subject to the
caveat above.
> Any reproduction, publication, communication, re-transmission,
> disclosure, dissemination or other use of the information contained
> in this e-mail by persons or entities other than the intended
> recipient is prohibited.
Oops!
--
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.samba.org/archive/linux/attachments/20050512/0f72ea90/attachment.bin
More information about the linux
mailing list