System Administration
Showing results for 
Search instead for 
Do you mean 

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

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
Acclaimed Contributor 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...
Acclaimed Contributor 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.
Frequent Advisor

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

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