本文摘自PHP中文网,作者ringa_lee,侵删。
首先建立50万个文件:1 2 3 4 | test for i in $(seq 1 500000)
for > do
for > echo test >> $i .txt
for > done
|
1.rm
1 2 3 4 | 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不起作用。
2.find
1 2 | 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分钟。
3.find with delete
1 2 | test time find ./ -type f - delete
find ./ -type f - delete 0.43s user 11.21s system 2% cpu 9:13.38 total
|
用时9分钟。
阅读剩余部分
相关阅读 >>
Linux怎么安装telnet
Linux如何查看显卡驱动是否安装
Linux下如何查看php是否启动
Linux如何查看系统是32位还是64位
Linux中rpm是什么意思
Linux中.tar文件怎么解压
关于d1 或 d1ne 本地磁盘存储数据时的注意事项
Linux系统目录结构包括哪些
Linux如何重命名文件
Linux定时任务crontab命令详解
更多相关阅读请进入《Linux》频道 >>
转载请注明出处:木庄网络博客 » linux删除文件的6种方法(总结)