2

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

Good Person
  • 359
  • 6
  • 18
Pavel
  • 417
  • 1
  • 7
  • 17

1 Answers1

4

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/ {} +
John Kugelman
  • 103
  • 12
Andrew Domaszek
  • 5,163
  • 1
  • 15
  • 27
  • 2
    You probably want to use `-exec cp -fr {} +` so that cp is invoked with a full command line. – user9517 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
  • 1
    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