Linux目录下有100万个文件,如何快速删除
当然了,首先我们想到的一定是rm -f删除,但是rm -f删除的话 会报错,提示无法删除,因为太长了,rm命令无法删除
[root@localhost opt]#mkdir files
[root@localhost opt]#ls
files
[root@localhost opt]#cd files
[root@localhost files]#ls|wc -l
1000001
[root@localhost files]#rm -f *
-bash:/usr/bin/rm:Argument list too long
[root@localhost files]#ls -l -f > /tmp/filelist.txt
[root@localhost files]#mkdir /tmp/cxk
[root@localhost files]#rsync -av --delete /tmp/cxk /opt/files --exclude-form=/tmp/filelist.txt