Created
September 19, 2017 09:18
-
-
Save eexit/36bd70b660d0cf24dfe79bd114851f6f to your computer and use it in GitHub Desktop.
AWS S3 List + Rename Specific Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export AWS_ACCESS_KEY_ID= | |
export AWS_SECRET_ACCESS_KEY= | |
# Very importe: KEEP the --dryrun flag!! | |
aws s3 cp s3://bucket-name . --dryrun --recursive --exclude '*' --include '*.gzip' \ | |
| tr "\r" "\n" \ | |
| grep -v '^Completed ' \ | |
| cut -d' ' -f3 > filename |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export AWS_ACCESS_KEY_ID= | |
export AWS_SECRET_ACCESS_KEY= | |
while read l; do | |
dest=$(echo $l | sed 's/.gzip/.gz/') | |
# Remove the --dryrun flag whenever you feel confident with the dryrun output | |
aws s3 mv $l $dest --dryrun | |
done < filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment