Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have problem with this command:

 'cp' -fr /www/*-aws/* /www/mainhost/aws/awstatstotals/tmp/

Error is Argument list too long - I know many /www/-aws/ folders. I know that I can use FIND command, but I dont know how I can give two wildcard as folder paramater. Can you help me please?

Thank you Pavel

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Don't put wildcards in the folder parameter. Put them in the path parameter.

find /www -maxdepth 2 -path '*-aws/*' -exec cp -frt /www/mainhost/aws/awstatstotals/tmp/ {} +
share|improve this answer
You probably want to use -exec cp -fr {} + so that cp is invoked with a full command line. –  Iain May 20 '14 at 11:46
Thank you! but little mistake: find /www -path '-aws/' -maxdepth 1 find: warning: you have specified the -maxdepth option after a non-option argument -path, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.- + right depth is 2 –  Pavel May 20 '14 at 11:48
Oops, never seen that warn before. I included maxdepth so cp doesn't blow up when recursing--guess I need to watch the order. Added '+' per @Iain 's suggestion. –  Andrew Domaszek May 20 '14 at 11:54
Huh, tried to run with + and a trailing destination per the suggestion. find doesn't like that, so I removed it. If someone wants to edit it so + works, I'd appreciate that. –  Andrew Domaszek May 20 '14 at 12:02
Edited. To use + you must also use cp -t so you can put the target directory first. –  John Kugelman May 20 '14 at 15:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.