Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

/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
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 \;