0

I tried this

s3cmd ls s3://somebucket/data/ | awk '{print $4}' | xargs -I %s s3cmd -v -c s3.cfg cp %s 's3://anotherbucket/data/' && s3cmd -c s3.cfg rm %s -v

it does not work, of course, because the second command (s3cmd rm) is not treated as part of the xargs argument...

How can I do it?

Background is that the move operation of the s3cmd in my case appears not to delete the source file, so I wanted to replace it with a copy and a delete, which appears to work.

4

1 回答 1

0

我最终只是调用了 sh (从 xarg 手册页中获取了该提示)并从那里开始工作,如下所示:

s3cmd ls s3://somebucket/data/ | awk '{打印 $4}' | xargs -n 1 sh -c 's3cmd -v -c s3.cfg cp $0 's3://anotherbucket/data/'; s3cmd -c s3.cfg rm $0 -v';

于 2013-04-23T14:00:57.427 回答