最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - AWS CLI error with delete objects recursively using include, exclude - Stack Overflow

programmeradmin0浏览0评论

I have various sub-directories inside my s3 bucket which contain 2 files, namely:

  1. pavement_suitability_final_result.gpkg
  2. Intermediate_Part1_output.gpkg

I wish to delete only the files named as Intermediate_Part1_output.gpkg, leaving the pavement_suitability_final_result.gpkg intact.

I tried the below commands, with no success:

  1. aws s3 rm s3://aitl-data-bucket-backup/4_8_2_processed/ --recursive --exclude "pavement_suitability_final_result.gpkg" --include "Intermediate_Part1_output.gpkg" --dryrun This deletes both the files ignoring my exclude command.

  2. aws s3 rm s3://aitl-data-bucket-backup/4_8_2_processed/ --recursive --exclude "*" --include "Intermediate_Part1_output.gpkg" --dryrun This also deletes both the files ignoring my include command.

Tried various other combinations, but to no avail.

I have various sub-directories inside my s3 bucket which contain 2 files, namely:

  1. pavement_suitability_final_result.gpkg
  2. Intermediate_Part1_output.gpkg

I wish to delete only the files named as Intermediate_Part1_output.gpkg, leaving the pavement_suitability_final_result.gpkg intact.

I tried the below commands, with no success:

  1. aws s3 rm s3://aitl-data-bucket-backup/4_8_2_processed/ --recursive --exclude "pavement_suitability_final_result.gpkg" --include "Intermediate_Part1_output.gpkg" --dryrun This deletes both the files ignoring my exclude command.

  2. aws s3 rm s3://aitl-data-bucket-backup/4_8_2_processed/ --recursive --exclude "*" --include "Intermediate_Part1_output.gpkg" --dryrun This also deletes both the files ignoring my include command.

Tried various other combinations, but to no avail.

Share Improve this question edited Mar 29 at 0:11 John Rotenstein 270k28 gold badges447 silver badges531 bronze badges Recognized by AWS Collective asked Mar 28 at 18:31 Swathi VenkateshSwathi Venkatesh 53 bronze badges 2
  • I suspect that it looks at the provided name as the full path of the object rather than just the 'filename' portion. Try something like: --exclude "*" --include "*/Intermediate_Part1_output.gpkg" to allow it to work in subdirectories too. – John Rotenstein Commented Mar 29 at 0:12
  • @JohnRotenstein Thank you very much, it worked! Earlier, I had tried using --include "/Intermediate_Part1_output.gpkg" but guess it needed the * too. If you could post your comment as an answer, I would be happy to mark it as accepted. – Swathi Venkatesh Commented Mar 31 at 9:44
Add a comment  | 

1 Answer 1

Reset to default 0

I suspect that it looks at the provided name as the full path of the object rather than just the 'filename' portion.

Try something like:

--exclude "*" --include "*/Intermediate_Part1_output.gpkg"

This will look for that filename in subdirectories too.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论