免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8580 | 回复: 3
打印 上一主题 下一主题

请问为何会报"-bash: /bin/ls: Argument list too long"错误? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-09 10:26 |只看该作者 |倒序浏览
请问为何会报"-bash: /bin/ls: Argument list too long"错误?是否有解决办法?是不是我的linux版本问题?谢谢指点!

cdrserver1:/zxindata/cdrftp> ls det/*200702*|wc -w
-bash: /bin/ls: Argument list too long
      0
cdrserver1:/zxindata/cdrftp> uname -a
Linux cdrserver1 2.4.21-138-smp #1 SMP Fri Oct 31 00:51:31 UTC 2003 i686 unknown

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
2 [报告]
发表于 2007-03-09 10:55 |只看该作者
Sounds as if you are experiencing a limit with the operating system
that cannot be changed. .... How many files were you expecting back from the ls listing .... a large number I suspect ?

The file /usr/include/sys/param.h defines
the variable NCARGS, which in turn defines the size for the argument
list. There is no way to change this value.... although the comments in
this file seem to indicate it is changeable, remember that all of the
Operating System has already been compiled based on the header file in
its current state.

You can try to break your "ls" command into smaller pieces, or use other code method.

论坛徽章:
0
3 [报告]
发表于 2007-03-11 12:04 |只看该作者
试试ls det/*200702*|xargs wc -w或find det -name *200702* -exec wc-w {} \;
也许可以解决你的问题,具体的解释请查看man

注意:第二个命令结尾要加";"哦

论坛徽章:
0
4 [报告]
发表于 2007-03-11 12:08 |只看该作者
使用通配符后,多数 shell 会将它自动转换成一长串参数列表。如果目录下面的文件匹配通配符的结果颇多,就可能导致产生这样的错误。不妨用 find 试试。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP