Linux: rm 删除文件太多出错的问题解决

2010年1月6日 由 月影鹏鹏 留言 »

Linux: rm and the ‘Argument list too long’ error message.

假设你要删除的目录中的词’spam’开头的所有文件:

[root@yoursite filter]# rm spam*
bash: /bin/rm: Argument list too long

错误: 这发生在您试图删除一个目录在同一时间太多的文件-它似乎是有极限的….

为了解决这个问题

使用  ‘find’ 到 管道来匹配文件到 ‘rm’,一次一个

[root@yoursite filter]# find . -name ’spam*’ | xargs rm

问题解决:本文来自鹏鹏工作室月影鹏鹏 http://jk.scanmon.com

Linux: rm and the ‘Argument list too long’ error message.


Let’s say you wanted to delete all the files in a directory that begins with the word ’spam’:

[root@yoursite filter]# rm spam*
bash: /bin/rm: Argument list too long

ERROR!

This happens when you are trying to delete too many files in a directory at the same time – it seems rm has limits ….

To solve the problem:

Use ‘find’ to pipe all the matching files to ‘rm’, one at a time.

[root@yoursite filter]# find . -name ’spam*’ | xargs rm
广告位

留言