Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nguyentienlong/7b0c899fcd664e5dc78268436dc8ec8f to your computer and use it in GitHub Desktop.
Save nguyentienlong/7b0c899fcd664e5dc78268436dc8ec8f to your computer and use it in GitHub Desktop.
aws cli - copy and flatten nested s3 files structure
aws s3 ls source-bucket-name - recursive | grep -E "\w+\.+" | awk -F" " '{for(i=4; i<=NF; i++){printf "s3://%s", $i}; printf "\n"}' | head -n5 | xargs -I$ aws s3 cp $ s3://destination-bucket-name/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment