Argument list too long错误

本文介绍了在删除大量文件时遇到的Argumentlisttoolong错误及其解决办法。通过使用find命令结合exec选项或ls配合xargs命令来绕过shell参数长度限制,实现高效批量删除。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原贴:http://www.zhangjianfeng.com/?p=358

Argument list too long错误

删除文件时,报"-bash: /bin/rm: Argument list too long"错误.查了一下,
[root@srv1 mqueue]# ls -l |wc -l
 319913
应该是文件数量太大了吧,记得应该是shell的限制,rm mv cp都受此限制。
解决方法:find所有文件,然后送给rm删除.
find /var/spool/mqueue -type f -exec rm {} /;

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script> name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/cpa/ads?client=ca-pub-9932809095109167&cpa_choice=CAEaCG25ta-KCIutUBJQBVAtUAdQQ1AvUEdQAw&oe=utf-8&dt=1190277355781&lmt=1190277355&format=468x60_as&output=html&correlator=1190277355765&channel=9299699904&url=https%3A%2F%2Fptop.only.wip.la%3A443%2Fhttp%2Fwww.zhangjianfeng.com%2F%3Fp%3D358&region=_google_cpa_region_&ref=https%3A%2F%2Fptop.only.wip.la%3A443%2Fhttp%2Fwww.google.cn%2Fsearch%3Fcomplete%3D1%26hl%3Dzh-CN%26ie%3DGB2312%26q%3Dlinux%2Brm%2Bargument%2Btoo%2Blong%26btnG%3DGoogle%2B%25CB%25D1%25CB%25F7%26meta%3D%26aq%3Dnull&cc=100&ga_vid=636176395.1190277356&ga_sid=1190277356&ga_hid=2072357979&flash=9&u_h=1024&u_w=1280&u_ah=904&u_aw=1280&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="468" scrolling="no" height="60" allowtransparency="allowtransparency">
##最后修改日期, Thursday, October 12th, 2006 2:30 pm##  

 

2007年09月

以root身份进入/var/spool/clientmqueue/
执行:
ls|xargs rm -f 就能全部删除了
这样效率比较高

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值