Remove zero bytes files in folder

Hi,

Please shed some light on how to quickly remove all the zero bytes in which there are some mixtures of more than zero bytes in it.

For eg:
> ls -lrt

-rw-r--r-- 1 ab noen 0 Jul 27 15:47 supplier_mp.unl
-rw-rw-r-- 1 ab noen 507 Aug 5 14:13 glance.err
-rw-r--r-- 1 ab noen 0 Aug 15 09:46 aaa.txt
-rw-r--r-- 1 ab noen 662 Aug 16 15:15 role999
-rw-r--r-- 1 ab noen 0 Aug 28 12:18 test
-rw-r--r-- 1 ab noen 566 Sep 11 08:48 cmd_srv_11092007
-rw-r--r-- 1 ab noen 0 Oct 3 16:15 run_new.log
-rw-r--r-- 1 ab noen 611 Oct 4 10:32 Query.in
-rw-r--r-- 1 ab noen 0 Oct 4 10:32 Response.log
-rw-r--r-- 1 ab noen 949 Oct 4 10:32 Request.log
-rw-r--r-- 1 ab noen 864 Oct 4 10:32 Summary.log
-rw-r--r-- 1 ab noen 424 Oct 9 01:57 skill.sh

Help..

To find zero length files use

find . -type f -size 0

so test with

find . -type f -size 0 | xargs ls -ld

if happy remove with

find . -type f -size 0 | xargs rm
1 Like

Alternatively

find /home/hari -type f -size 0 -exec rm {} \;
1 Like