Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search an Amazon S3 Bucket using Wildcards?

This stackoverflow answer helped a lot. However, I want to search for all PDFs inside a given bucket.

  1. I click "None".
  2. Start typing.
  3. I type *.pdf
  4. Press Enter

Nothing happens. Is there a way to use wildcards or regular expressions to filter bucket search results via the online S3 GUI console?

like image 856
nu everest Avatar asked Apr 30 '15 15:04

nu everest


People also ask

How do you search an Amazon S3 bucket?

Perhaps you're looking for something more complex, but if you landed here trying to figure out how to simply find an object (file) by it's title, it's crazy simple: open the bucket, select "none" on the right hand side, and start typing in the file name.

Can you query an S3 bucket?

Amazon S3 Select and Amazon S3 Glacier Select enable customers to run structured query language SQL queries directly on data stored in S3 and Amazon S3 Glacier. With S3 Select, you simply store your data on S3 and query using SQL statements to filter the contents of S3 objects, retrieving only the data that you need.


2 Answers

As stated in a comment, Amazon's UI can only be used to search by prefix as per their own documentation:

http://docs.aws.amazon.com/AmazonS3/latest/UG/searching-for-objects-by-prefix.html

There are other methods of searching but they require a bit of effort. Just to name two options, AWS-CLI application or Boto3 for Python.

I know this post is old but it is high on Google's list for s3 searching and does not have an accepted answer. The other answer by Harish is linking to a dead site.

UPDATE 2020/03/03: AWS link above has been removed. This is a link to a very similar topic that was as close as I could find. https://docs.aws.amazon.com/AmazonS3/latest/dev/ListingKeysHierarchy.html

like image 173
Michael Hohlios Avatar answered Sep 26 '22 17:09

Michael Hohlios


AWS CLI search: In AWS Console,we can search objects within the directory only but not in entire directories, that too with prefix name of the file only(S3 Search limitation).

The best way is to use AWS CLI with below command in Linux OS

aws s3 ls s3://bucket_name/ --recursive | grep search_word | cut -c 32-  

Searching files with wildcards

aws s3 ls s3://bucket_name/ --recursive |grep '*.pdf' 
like image 29
Tech Support Avatar answered Sep 24 '22 17:09

Tech Support