`
h13327840728
  • 浏览: 18022 次
  • 性别: Icon_minigender_1
  • 来自: 南京
最近访客 更多访客>>
社区版块
存档分类
最新评论

rm * 删除文件数过多出错 /bin/rm: Argument list too

阅读更多
Linux 系统中当单个目录中文件数过多时,试图用 rm * 来删除所有文件会报错 /bin/rm: Argument list too long.

据说这是因为 Linux 内核中所有 exec 系函数(execl, execlp, execle 等)最终调用的都是 execve() , 而execve 是通过一块 128k 的内存空间来保存用以传递给新进程的命令参数和环境变量。当像 rm 这些命令产生的命令行参数超过 128k 的时候, Linux kernel 就报 E2BIG 错误了。

解决方法是用 find 命令先找出希望删除的文件名再用管道批次传递给 rm 去删除。比如要删除 sendmail 堆积起来的mqueue 目录下的文件:

find /var/spool/mqueue/ -type f -name '*' -print0 | xargs -0 rm

(-0 参数防止文件名中有空格导致被 rm 认作是两个不同的文件。)

分享到:
评论

相关推荐

    嵌入式系统设计与应用实验串口通信

    /* 包含文件 */ #include "def.h" #include "2410lib.h" #include "option.h" #include "2410addr.h" #include "interrupt.h" /******************************************************************** // Function...

    synology-wireguard:WireGuard对某些Synology NAS驱动器的支持

    WireGuard对Synology NAS的支持 该软件包增加了对Synology NAS驱动器的WireGuard支持。 它提供了WireGuard内核模块和wg / wg-quick命令。 免责声明 ... 您将收到错误消息Error: argument "suppress_pre

    tomcrypt.h

    CRYPT_INVALID_ARG, /* Generic invalid argument */ CRYPT_FILE_NOTFOUND, /* File Not Found */ CRYPT_PK_INVALID_TYPE, /* Invalid type of PK key */ CRYPT_PK_INVALID_SYSTEM,/* Invalid PK system ...

    pb9 调用 des64.dll 做的加密解密demo

    pb9 调用 des64.dll 做的加密解密demo... Argument DataType Description Szin string 需加密的字符串 szout string 加密后输出字符串 key string 密钥 inlen int 需加密的字符串的长度 flag uint 0:解密,1:加密

    dubbo技术介绍

    <dubbo:argument/> <dubbo:parameter/> 协议参考手册 dubbo:// rmi:// hessian:// http:// webservice:// thrift:// memcached:// redis:// 注册中心参考手册 Multicast注册中心 Zookeeper注册中心 Redis注册中心 ...

    Laravel 5.4中migrate报错: Specified key was too long error的解决

    但方便的同时也会伴随着一些问题,下面这篇文章将详细给大家介绍关于Laravel5.4中migrate报错Specified key was too long error的解决方法,下面话不多说了,来一起看看详细的介绍吧。 发现问题 Laravel 5.4默认使用...

    bmi160调通bmi160的ACC+GYR_20160907.7z

    /*gsensor info*/ static struct sw_device_info gsensors[] = { { "bma250", 0, {0x18, 0x19, 0x08, 0x38}, 0x00, {0x02,0x03,0xf9,0xf8}, 0}, }; Z:\home\wwt\only_bma250_r58\lichee\tools\pack\chips\sun8iw...

    Visual Studio 2005 宏注释

    // Argument: // HINSTANCE hInstance // int nCmdShow // ReturnType: BOOL // Description: ... // Created: 于金山 Time: 2009-03-12 05:00:14 // Modified: 于金山 Time: 2009-03-12 05:05:01 // Modified: ...

    一步步写嵌入式操作系统.zip

    mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments __open_missing_mode (); 解决方法: 修改skyeye-1.2.6_rc1/device/nandflash/nandflash_smallblock...

    NCKU_littledenden:登大人网站

    NCKU Little Den Den NCKU新生营 开始 安装npm: sudo apt-get install npm 安装节点模块和Bower组件: ./func init 这将在dist文件夹中执行npm ... 请将jsx文件放在src文件夹中,然后jsx会将文件转换为dist文

    jquery1.9.1中文版

    */ core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, //用于分开空格 core_rnotwhite = /\S+/g, //查找非空白字符串 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE...

    jquery1.9.1中文汉化版

    */ core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, //用于分开空格 core_rnotwhite = /\S+/g, //查找非空白字符串 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and ...

    Linux删除文件不同方法效率对比

    测试一下Linux下面删除大量文件的效率。 首先建立50万个文件 ...zsh: argument list too long: rm rm -f * 3.63s user 0.29s system 98% cpu 3.985 total 由于文件数量过多,rm不起作用。 2. fin

    NTLM PPROXY client的实现(C source code)

    /************************************ 算法:MD4和MD5 *********************************/ //从RFC1320 The MD4 Message-Digest Algorithm的附录 //从RFC1321 The MD5 Message-Digest Algorithm的附录 /* ...

    linux删除大量文件的6种方法

    首先建立50万个文件 代码如下:test for i in $(seq 1 500000)for> ... yzsh: argument list too long: rmrm -f * 3.63s user 0.29s system 98% cpu 3.985 total 由于文件数量过多,rm不起作用。 2 find 代码如下: 

    srcutils:修改go程序的工具

    srcutils 在golang代码库上执行修改的实用程序许可证:ISC安装$ go get github.com/tmc/srcutils/cmd/add_argument实用工具add_argument 向代码库添加新参数。 例子: $ add_argument -w -arg= " ctx context....

    cocos2d-x c++的iconv.rar

    #define ICONV_SET_FALLBACKS 6 /* const struct iconv_fallbacks *argument */ /* Listing of locale independent encodings. */ #define iconvlist libiconvlist extern void iconvlist (int (*do_one) (unsigned...

    GigaDevice.GD32E23x_DFP.1.0.0.pack

    This is a list of ARM Cortex-M based microcontrollers that are supported by Software Packs and can be used in MDK Version 5. For maintaining existing MDK Version 4 projects, or using devices that are...

Global site tag (gtag.js) - Google Analytics