/usr/bin/cp: the parameter list is too long (411 Views)
Reply
Occasional Contributor
ahsiangsiang
Posts: 4
Registered: ‎03-19-2009
Message 1 of 4 (411 Views)

/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
Please use plain text.
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 2 of 4 (411 Views)

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...
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,977
Registered: ‎03-06-2006
Message 3 of 4 (411 Views)

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.
Please use plain text.
Frequent Advisor
msaygak
Posts: 47
Registered: ‎04-22-2008
Message 4 of 4 (411 Views)

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

try to use
find /path -exec cp { } /new/path \;
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation