Site icon Ryadel

How to find and list zero byte files in Windows and Linux

How to execute PHP7 CLI commands with cPanel and EasyApache 4 - PHP7 CLI path

Today I was asked to write a simple batch script to locate all zero-byte files within a Windows Server machine.

The answer was definitely simple, thanks to the powerful FOR command available in cmd.exe:

Windows

This will create a list.txt file containing all the zero-byte files found within the current execution folder and all its subdirectories. If you want them on screen, simply remove the > list.txt at the end.

Linux

Since I made it for Windows, I thought it could do the same with Linux. Here's the one-liner:

Again, if you want them on screen, remove the > list.txt at the end.

That's about it!

 

Exit mobile version