1

I have two AWS S3 buckets that have mostly the same content but with a few differences. How can I list the files that are in one bucket but not in the other bucket?

1 Answer 1

1

Just install the AWS CLI, then set it up as Amazon Web Services specifies here, then type:

aws s3 ls --recursive s3://BucketN1 > listbucket1.txt

aws s3 ls --recursive s3://BucketN2 > listbucket2.txt

diff -u listbucket1.txt listbucket2.txt| grep '^-[^-]' | sed 's/^-//'

Ensure the first list contains the files you want to show, otherwise flip the order of the two lists.

Relevant addendum: if you're on Windows you can install cygwin or wsl in order to have diff available.

1
  • S3 Inventory can also be used to do something similar and will probably be more efficient if there are a large number of objects. Also does not require the use of the CLI
    – Tim P
    Commented May 2 at 14:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .