Operating System - HP-UX
1752716 Members
5702 Online
108789 Solutions
New Discussion юеВ

/usr/bin/cp: the parameter list is too long

 
ahsiangsiang
Occasional Contributor

/usr/bin/cp: the parameter list is too long

Hi,

here is my machine info
B.11.11 U

i have a problem when copying, moving or listing the directory which contains a lot of files.

search around the forum but no go

#getconf ARG_MAX
2048000

i did try xargs command but still no go.
ls $A | xargs -i -t cp $A/ {} $B/ {}

can somebody help me on this matter. Thanks
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: /usr/bin/cp: the parameter list is too long

Hi:

Given you example where :

# ls $A ...

...you are still telling the shell to glob and, in your case, the argument list generated exceeds the maximum size allowed.

You need to divide-and-conquer. One way would be to handle the contents of multiple sub-directories. You might also leverage 'find' matching its '-name' argument in its selection.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: /usr/bin/cp: the parameter list is too long

What does $A have? A directory or a pattern?
The former shouldn't have problems.
msaygak
Frequent Advisor

Re: /usr/bin/cp: the parameter list is too long

try to use
find /path -exec cp { } /new/path \;