cp: Argument list too long

der.hans plug-discuss@lists.plug.phoenix.az.us
Mon, 9 Dec 2002 14:28:27 -0700 (MST)


Am 09. Dec, 2002 schw=E4tzte Bill Earl so:

> Is anyone aware of a separate file copying or moving (I need to do both,
> depending on the situation) utility that can handle very large numbers
> of files?  Would switching to a different shell solve this (if so, which
> one?), or is it a limit on the cp and mv commands?

find /dir | cpio -pvdm /new/loc

That *might* work.

find /dir -exec cp -p {} /new/loc \; -exec rm -f {} \;

That *should* work and might finish before you retire :).

#!/bin/sh

alpha=3D"a b c d e f g" # fill to z
ALPHA=3D"A B C D E F G" # fill to Z
digits=3D`seq 0 9`

for i in $alpha $ALPHA $digits do
  for j in $alpha $ALPHA $digits do
    for k in $alpha $ALPHA $digits do
      mv /dir/${i}${j}${k}* /new/loc
    done
  done
done

Add more layers if you need. You might as well use Python, PHP or Perl if
you can, though.

Also look at the bash manpage, I think there's a variable to change to
extend the default max # of arguments, but it probably doesn't go to 250k.

ciao,

der.hans
--=20
#  https://www.LuftHans.com/    http://www.TOLISGroup.com/
#  The Internet is the front line of the battle
#  to protect our freedom. -- Nathaniel Borenstein