CentOS下下删除大量文件
文章目录
[CentOS下下删除大量文件]
首先建立50万个文件
➜ test for i in $(seq 1 500000);do echo text >>$i.txt;done
- rm
➜ test time rm -f *
zsh: sure you want to delete all the files in /home/hungerr/test [yn]? y
zsh: argument list too long: rm
rm -f * 3.63s user 0.29s system 98% cpu 3.985 total
由于文件数量过多,rm不起作用。
- find
➜ test time find ./ -type f -exec rm {} ;
find ./ -type f -exec rm {} ; 49.86s user 1032.13s system 41% cpu 43:19.17 total
大概43分钟,我的电脑。。。。。。边看视频边删的。
- find with delete
➜ test time find ./ -type f -delete
find ./ -type f -delete 0.43s user 11.21s system 2% cpu 9:13.38 total
用时9分钟。
- rsync
首先建立空文件夹blanktest
➜ ~ time rsync -a --delete blanktest/ test/
rsync -a --delete blanktest/ test/ 0.59s user 7.86s system 51% cpu 16.418 total
16s,很好很强大。

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论