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?
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:
$ aws s3 ls s3://bucket --recursive | grep ".*.txt.*"
Here's an example which mirrors the "exclude" functionality:
$ aws s3 ls s3://bucket --recursive | grep -v ".*.txt.*"
In Powershell:
Here's an example which mirrors the "include" functionality:
$ aws s3 ls s3://bucket --recursive | Select-String ".*.txt.*"
Here's an example which mirrors the "exclude" functionality:
$ aws s3 ls s3://bucket --recursive | Select-String ".*.txt.*" -NotMatch