in reply to Onliner magic to remove files
The find based methods in slashroot article are somewhat dubious. Firstly, -exec rm {} \; option will invoke rm for each and every file (also noted by the author). Gnu find offers a nifty feature for such occasions.
$ time find ./ -type f -exec rm {} \+
real 0m1.764s
Which builds up argument list, passing that to rm. It's more or less equivalent to the following (except there's no pipe/xargs involved):
$ time find ./ -type f -print0 | xargs -0 rm real 0m1.321s
Using -delete:
$ time find ./ -type f -delete real 0m0.795s
In parallel:
$ time find ./ -type f -print0 | xargs -0 -P4 -n10000 rm real 0m0.571s
Perl versions:
$ time perl -e 'for(<*>){((stat)[9]<(unlink))}'
real 0m2.917s
$ time perl -e 'unlink for <*>'
real 0m2.308s
Tests were run in a tmpfs backed directory; files created as in the reference article:
$ for i in $(seq 1 500000); do echo testing >> $i.txt; done
|
|---|