Removing Zero-Byte Files (0b)

I recently saw a server glitch where an automated system created thousands of files with no content—0b. Once they were created, they became really hard to remove.

I solved it by running:

find /srv/www/ -size 0b

This let me know where all the funky files were. Then I tested on a deep folder… and then:

find /srv/www/ -size 0b -delete

removed them all, allowing the system to re-publish them correctly.

2 thoughts on “Removing Zero-Byte Files (0b)”

  1. Would this work on directories, too? Say, if I had somehow
    accidentally uploaded hundreds of “_notes” directories back before
    I became an enlightened BBEdit user?

  2. Sure! Try this:

    find /srv/www/ -name '_notes' -delete

    (Of course, substitute /srv/www/ with the actual path to your website…

Comments are closed.