Search all directories on S3
For example, is it possible to search all directories in “20avh-logs” of S3?
Answer:
you can refer to objects in all layers by executing the “s3 ls” command of the AWS CLI with the “–recursive” option. Please check the following documents for details:
https://docs.aws.amazon.com/cli/latest/reference/s3/ls.html
aws s3 ls s3: // mybucket --recursive
Output:
2013-09-02 21:37:53 10 a.txt
2013-09-02 21:37:53 2863288 foo.zip
2013-09-02 21:32:57 23 foo / bar / .baz / a
2013-09-02 21:32:58 41 foo / bar / .baz / b
2013-09-02 21:32:57 281 foo / bar / .baz / c
2013-09-02 21:32:57 73 foo / bar / .baz / d
2013-09-02 21:32:57 452 foo / bar / .baz / e
2013-09-02 21:32:57 896 foo /bar/.baz/hooks/bar
2013-09-02 21:32:57 189 foo / bar / .baz / hooks / foo
2013-09-02 21:32:57 398 z.txt
Also, by adding the character string you want to search for with the grep command after the –recursive option as shown below, it is also possible to list only the objects with a specific character string from all layers in the bucket.
aws s3 ls s3://bucket name/ --recursive | grep string you want to search
October 3, 2022
shinchan79