I’m on the newest AWS CLI version – 2.7.24
Trying to list all the files from all the folders I have (with a certain extension) on this path:
s3://myfiles/folders/
"folders" have this structure:
folder1
- item
- item
folder2
- item
- item
folder3
- item
- item
My aws cli command is:
aws s3 ls –recursive s3://myfiles/folders/ -> Which works fine. But when I add –include, it doesn’t work. Error: unknown options
Example:
aws s3 ls –recursive –exclude * –include "*.txt" s3://myfiles/folders/
Error: Unknown options: –exclude, , –include,*.txt
I did pip install -U awscli
I tried a lot of internet and stackoverflow stuff but nothing worked.
Any ideas?
3
Answers
Currently there is no such option as
or
There is an open feature request for that, but no solution so far.
You can easily build the desired functionality by piping the result of the aws cli command to grep or similar.
In Bash:
Here’s an example which mirrors the "include" functionality:
Here’s an example which mirrors the "exclude" functionality:
In Powershell:
Here’s an example which mirrors the "include" functionality:
Here’s an example which mirrors the "exclude" functionality:
You can do expansions with s3
ls
if you want to match the beginning of the path…If I want to find all paths that start with a capital "C" inside a certain directory I can do this:
And it’ll match all folders that start with "C" inside
my-bucket/my-folder/
.