[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Argument list too long



On 2003-12-19 10:53:35 -0500, Derrick 'dman' Hudson wrote:
> On Fri, Dec 19, 2003 at 11:47:32AM +0200, Dobai-Pataky Balint wrote:
> | i have a webcam logging all motion into jpgs, my php code does lots with
> | it, except after i convert selected jpgs copied into the workin' folder,
> | and after conversion i'd like to rm them from php or by hand it'll give:
> | rm *.jpg
> | su: /bin/rm: Argument list too long
> 
> The problem is that the shell has a hard limit on the size (in bytes)
> of commands.

No, it's a kernel limit, not a shell limit. For instance, in zsh,
you wouldn't have any error with the rm builtin from the zsh/files
module.

> This limit is quite large (many times larger than cmd.exe on
> windows!) and you won't often run into it, except for example when
> using '*' in a large directory.

I often reach it with recursive globbing.

> Another option, not yet given, is :
> 
> find . -name \*.jpg | xargs rm

This is potentially dangerous (filenames may contain a \n character).
If you want to use find and xargs, do it correctly (see other posts).

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA



Reply to: