I want to move files from one s3 bucket to another s3 bucket.I want to move only files whose name starts with "part".I can do it by using java.But is it possible to do it with amazon CLI. Can we use GlobPattern in CLI. my object name are like: part0000 part0001
Yes, this is possible through the aws CLI, using the --include
and --exclude
options.
As an example, you can use the aws s3 sync
command to sync your part files:
aws s3 sync --exclude '*' --include 'part*' s3://my-amazing-bucket/ s3://my-other-bucket/
You can also use the cp
command, with the --recursive
flag:
aws s3 cp --recursive --exclude '*' --include 'part*' s3://my-amazing-bucket/ s3://my-other-bucket/
Explanation:
aws
: The aws CLI commands3
: The aws service to interface withsync
: The command to the service to do--exclude <value>
: The UNIX-style wildcard to ignore, except by include statements--include <value>
: The UNIX-style wildcard to act upon.As noted in the documentation, you can also specify --include
and --exclude
multiple times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With