I have a folder with 5000 files that I want to copy somewhere else.

When I do cp ../folder* ., I get the following error:

-bash: /bin/cp: Argument list too long

However, getconf ARG_MAX returns 262144.

$ echo ../folder* |wc
1 5015 69144

Is this normal? I had been able to copy all those files before.

  • 3
    ARG_MAX is a character limit, not an parameter count.
    – Jeff Schaller
    Aug 10, 2015 at 18:01

1 Answer 1


Use a program to iterate over the arguments:

e.g. find .. -type d -iname '*/folder*' -exec cp -a {} . \;

of manually iterate with a loop, such as:

for myDir in ../folder* ; do cp -a "$myDir" . ; done

There are many other ways, but one of the above should do the trick for you. (The for-loop example might be slower)

  • wouldn't find ... -exec cp ... + run into the very same problem of having too many arguments as find will batch the output or is there a limit for batching size with +?
    – FelixJN
    Aug 11, 2015 at 7:52
  • @Fiximan : I would consider it a bug in "find", if it offered "+" to batch arguments, without checking local system argument count limits. And since "find" is ancient software, they should have thought about, and fixed any bugs in this functionality decades ago. Aug 11, 2015 at 8:21

Not the answer you're looking for? Browse other questions tagged .