Skip to content

Instantly share code, notes, and snippets.

@tecmaverick
Created September 30, 2024 01:07
Show Gist options
  • Save tecmaverick/b34aad5e83a9b57e0874483bcc86e823 to your computer and use it in GitHub Desktop.
Save tecmaverick/b34aad5e83a9b57e0874483bcc86e823 to your computer and use it in GitHub Desktop.
AWS CLI - S3 List File Extensions
# Retrieves the list of unique file extensions, including those with multiple extensions like gz.txt
aws s3 ls s3://the_bucket_name/prefix_name --recursive | rev | cut -d "/" -f 1 | rev | cut -d "." -f 2- | sort | uniq
# Retrieves the count of file extensions in a given s3 prefix
aws s3 ls s3://the_bucket_name/prefix_name --recursive | rev | cut -d "/" -f 1 | rev | cut -d "." -f 2- | uniq -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment