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?
CodePudding user response:
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 -E ".*.txt.*"
Here's an example which mirrors the "exclude" functionality:
$ aws s3 ls s3://bucket --recursive | grep -E -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
CodePudding user response:
Currently there is no such option as aws s3 ls --include or --exclude. There is an open feature request for that, but no solution so far.