Re: File Limit in Kernel?

Richard B. Johnson (root@chaos.analogic.com)
Tue, 12 Nov 2002 11:08:09 -0500 (EST)


On 12 Nov 2002, Adam Voigt wrote:

> I have a directory with 39,000 files in it, and I'm trying to use the cp
> command to copy them into another directory, and neither the cp or the
> mv command will work, they both same "argument list too long" when I
> use:
>
> cp -f * /usr/local/www/images
>
> or
>
> mv -f * /usr/local/www/images
>
> Is this a kernel limitation? If yes, how can I get around it?
> If no, anyone know a workaround? I appreciate it.
>

The '*' is expanded by your shell to be a command-line that has
39,000 file-names in it! It is probably way too long for a command-
line (argument list).

The easiest way is to do:

mv -f a* /usr/local/www/images
mv -f b* /usr/local/www/images
mv -f c* /usr/local/www/images

... until the remaining argument list is short enough for the '*' only.

You can also do a loop in a shell if the shell's internal buffer is
big enough for the expanded '*' ...

for x in * ; do mv -f $x /usr/local/www/images ; done

Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Bush : The Fourth Reich of America

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/