User Tools

Site Tools


Tags Cloud

This is an old revision of the document!

Быстрое удаление большого количества файлов

generate files

for i in $(seq 1 1000000); do echo testing >> $i.txt; done


time rm -f *
-bash: /bin/rm: Argument list too long
real    0m11.126s
user    0m9.673s
sys     0m1.278s

find with -exec rm

time find ./ -type f -exec rm {} \;
real    14m51.735s
user    2m24.330s
sys     9m48.743s

find with -delete

time find ./ -type f -delete
real    5m11.937s
user    0m1.259s
sys     0m28.441s


time perl -e 'for(<*>){((stat)[9]<(unlink))}'
real    1m0.488s
user    0m7.023s
sys     0m27.403s

rsync - empty test dir

rsync -a --delete /home/blanktest/ /home/test/
real    2m52.502s
user    0m2.772s
sys     0m32.649s
speedup_rm.1424901540.txt.gz · Last modified: 2015/02/25 21:59 by kyxap