Using a kshell, you can test for a file of greater than 0 bytes using if -s.
#!/bin/ksh
cd - to your directory
for filename in `ls -1`
do
if [[ -s $filename ]] then
echo "Do nothing"
else
echo "Removing file"
rm $filename
fi
done
Take care when setting up ant script which uses rm - test it thoroughly on dummy files before using it live.
Just noticed, the second find in my response is missing a . (period) as in find . -size 0 -exec rm {} \;
Don't forget that if there's not too many of them, it might be worth including the -i (interactive) option after rm so that you are prompted that you really (really) want to delete the file. Cheers.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.