Skip to content

Instantly share code, notes, and snippets.

@KryptikOne
Last active September 24, 2018 20:57
Show Gist options
  • Select an option

  • Save KryptikOne/c61b370544bd4aef41de1ef21813df44 to your computer and use it in GitHub Desktop.

Select an option

Save KryptikOne/c61b370544bd4aef41de1ef21813df44 to your computer and use it in GitHub Desktop.

Reading/Listing

List the contents of the bucket

aws s3 ls s3://BUCKET_NAME

Copying/Moving

(To Local)

To recursively copy the contents of the WHOLE bucket to the specified directory

aws s3 cp s3://BUCKET_NAME/ ./LOCAL_PATH --recursive

To recursively copy the contents of the a specific directory in the bucket to the specified directory

aws s3 cp s3://BUCKET_NAME/REMOTE_PATH/ ./LOCAL_PATH --recursive

Copy ".txt" and ".csv" files from S3 bucket to local working directory

aws s3 cp s3://BUCKET_NAME/ ./LOCAL_PATH --recursive --exclude "*" --include "*.txt" --include "*.csv"

(From Local)

Copy all files from current working directory to the bucket

aws s3 cp ./ s3://BUCKET_NAME/ --recursive

Deleting/Removing

Delete a specific file from the bucket

aws s3 rm s3://BUCKET_NAME/path/MyFile.txt

Delete all ".js" files from the bucket

aws s3 rm s3://BUCKET_NAME/ --recursive --exclude "*" --include "*.js"

Delete all files in the bucket with a file extension beginning with "j" or "c" (".csv", ".java, ".json", ."jpeg", etc.)

aws s3 rm s3://BUCKET_NAME/ --recursive --exclude "*" --include "*.[jc]*"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment