AWS CLI Commands

AWS CLI Commands



I want to get list of all files in S3 bucket with particular naming pattern.
For Eg if i have files like


aaaa2018-05-01
aaaa2018-05-23
aaaa2018-06-30
aaaa2018-06-21



I need to get list of all files for 5th month.Output should look like:


aaaa2018-05-01
aaaa2018-05-23



I executed the following command and the result was empty:


aws s3api list-objects --bucket bucketname --query "Contents[?contains(Key, 'aaaa2018-05-*')]" > s3list05.txt



when i check the s3list05.txt its empty. Also i tried the below command and


aws s3 ls s3:bucketname --recursive | grep aaaa2018-05* > s3list05.txt



this command lists me all the objects present in the file.
Kindly let me know the exact command to get desired output.




2 Answers
2



You are almost there. Try this:


aws s3 ls s3://bucketname --recursive | grep aaaa2018-05



or


aws s3 ls bucketname --recursive | grep aaaa2018-05





this option did work for me.I didnt try the first one as this one worked for me.Thanks a lot for the response
– Aish Mahesh
Sep 5 at 14:45



The Contains parameter doesn't need a wildcard:


Contains


aws s3api list-objects --bucket bucketname --query "Contents[?contains(Key, 'aaaa2018-05')].[Key]" --output text



This provides a list of Keys.



--output text removes the JSON formatting.


--output text



Using [Key] instead of just Key puts them all on one line.


[Key]


Key





Thanks for the response i did try this option and this also worked for me as i wanted.Thank you
– Aish Mahesh
Sep 11 at 14:00



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế