How to Delete Zero-Length Files

๐Ÿ”น Delete All Zero-Length Files in Current Directory

find . -type f -empty -delete

๐Ÿ”น Dry Run (See What Will Be Deleted)

find . -type f -empty

๐Ÿ”น Delete Only in a Specific Directory (Non-Recursive)

find ./rc-locals -maxdepth 1 -type f -empty -delete

๐Ÿ”น Delete Only Certain File Types (e.g., .rc.local)

find . -type f -name "*.rc.local" -empty -delete

๐Ÿงผ Notes

This helps avoid accidentally deleting unrelated files. For added safety, consider running the dry run command first before using -delete.