Skip to content

Instantly share code, notes, and snippets.

@arc279
Created April 18, 2018 07:19
Show Gist options
  • Save arc279/945057b74c56bafbb4923a64fffff472 to your computer and use it in GitHub Desktop.
Save arc279/945057b74c56bafbb4923a64fffff472 to your computer and use it in GitHub Desktop.
s3のファイルをまとめて消すコマンドを出力
BUCKET_NAME=some_bucket
PATTERN='some_pattern'
aws s3 ls --recursive s3://${BUCKET_NAME} | rev | cut -f1 -d' ' | rev > file_lst
cat file_lst | grep -oP "$PATTERN" | xargs -I{} echo "aws s3 rm --recursive 's3://${BUCKET_NAME}/{}'" > rm_cmd.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment