Consider that there are countless number of files under /src/
cp /src/* /dst/
How many files
cp will successfully process?
That depends greatly on the system and version, on the number and size of the arguments and on the number and size of environment variable names.
Traditionally on Unix, the limit (as reported by
Bearing in mind that
On Linux, it depends on the version. The behaviour there changed recently where it's not longer a fixed space.
Checking on Linux 3.11,
That limit is on the cumulative size of the argument and environment strings and some overhead (I suspect due to alignment consideration on page boundaries). The size of the pointers is not taken into account.
Searching for the limit, I get:
The maximum cumulative size before breaking in that case is:
Now, that does not mean that you can pass 1 million empty arguments. On a 64 bit system, 1 million empty arguments make a pointer list of 8MB, which would be above my stack size of 4MiB.
(you'll noticed it's not a E2BIG error. I'm not sure at which point the process gets killed there though if it's within the
Also note (still on Linux 3.11) that the maximum size of a single argument or environment string is 128kiB, regardless of the size the stack.
That will depend on the value of ARG_MAX which can change between systems. To find out the value for your system run (showing the result on mine as an example):
This has nothing to do with
To answer your main question then,
The way of getting around these errors is to run your command in a loop: