bash: /bin/rm: Argument list too long
I've noticed recently that rm has a limit on howmany files it can handle in a glob. Somewhere along the line some of my mailing list directories lost their expiration settings, and filled with 10s of thousands of messages. KMail was not completing the move to trash when given over an hour. I decided to delete the messages by hand, so I went into the ~/Mail directory and tried rm in the relevant subdirectories. That's when I saw "bash: /bin/rm: Argument list too long". I did for f in *; do rm $f; done, and that worked. I'm just curious. How many's too many? -- Regards, Steven
Steven, On Tuesday 14 June 2005 17:02, Steven T. Hatton wrote:
I've noticed recently that rm has a limit on howmany files it can handle in a glob.
A little clarification: - Shells perform globbing. They generate the list of arguments (file / directory names) that match the glob patterns given in the command being executed. - The limit is on argument lists + environment variables, is imposed by the kernel and applies to all program invocations (all uses of all variants of the exec(2) family of system calls).
Somewhere along the line some of my mailing list directories lost their expiration settings, and filled with 10s of thousands of messages. KMail was not completing the move to trash when given over an hour. I decided to delete the messages by hand, so I went into the ~/Mail directory and tried rm in the relevant subdirectories. ... That's when I saw "bash: /bin/rm: Argument list too long". I did for f in *; do rm $f; done, and that worked. I'm just curious. How many's too many?
% egrep ARG_MAX /usr/include/linux/limits.h #define ARG_MAX 131072 /* # bytes of args + environ for exec() */ I.e., 128K. Keep in mind, that includes space required both by command line arguments (including the NUL byte terminating each individual argument string) and environment variables (including the variable name, the equal sign, the value and a terminating NUL byte).
-- Regards, Steven
Randall Schulz
participants (2)
-
Randall R Schulz
-
Steven T. Hatton