How to find zero byte files in Amazon S3

There is no direct process to search files of zero bytes in size at amazon s3. You can do it by listing all objects and then sort that items on the basis of size, then you can get all zero file size together.

if you want get list of all file having size zero then you can use Bucket Explorer and list the objects of the selected bucket then click on size header (sort by size) it will keep together files size of zero byte together.

Disclosure: I am a developer of Bucket Explorer.


Combining s3cmd with awk should do the trick easily.

Note: s3cmd outputs 4 columns, date, time, size and name. You want to match the size (column 3) against 0 and output the object name (column 4). This should do the trick...

$ s3cmd ls -r s3://bucketname | awk '{if ($3 == 0) print $4}'
s3://bucketname/root/
s3://bucketname/root/e

If you want to see all information, just drop the $4 so that it only says print.

$ s3cmd ls -r s3://bucketname | awk '{if ($3 == 0) print}' 
2013-03-04 06:28         0   s3://bucketname/root/
2013-03-04 06:28         0   s3://bucketname/root/e

Memory-wise, this should be fine as it's a simple bucket listing.