linux删除文件的6种方法(总结)


本文摘自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下lvm软件介绍――弹性伸缩文件系统的大小

Linux df命令详解

有哪些Linux系统

Linux使用手册之安装clion和运行使用总结

Linux怎么查看cpu占用率(使用率)?

关于自动快照策略类型和自动快照策略的详细设置信息

怎么查看Linux的版本信息

Linux中如何查看机器是多少位

如何结合产品和运维架构经验打造云端的数据安全

Linux如何恢复删除的文件

更多相关阅读请进入《Linux》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...