Find and delete zero sized files

Written by Peter Davies on .

I recently had a "disk full" issue on a server but even after clearing out the apache logs that had failed to rotate the website that the server was running showed broken images where thumbnails should be.

After a little investigation it turned out the thumbnail code had tried to replace/create "zero" sized thumbnail images. The complication was that the images were spread across multiple directories meaning that it was going to be almost impossible to delete manually.

A combination of Google searches resulted in:

find ./ -type f -size 0 -exec rm {} \;

Very useful! And of course I backed up first!