[Techtalk] zero byte file deletes
Dan
dan at cellectivity.com
Mon Nov 7 23:52:51 EST 2005
> > Is there a way to delete zero byte files
> > in a directory?
>
> find . -maxdepth 1 -size 0 -exec rm -f {} \;
Depending on the context, it might be more convenient to use bash's "-s"
flag, which tells you if a file has a size greater than zero:
# If size of $file is not greater than zero,
# delete it.
if [ ! -s $file ]
then
rm $file
fi
--
In 1750, Ben Franklin got a bill to transport "grains" through the
Pennsylvania House of Representatives. The House had many pacifist
quakers, who didn't read the bill carefully enough to see that it
was for the transport of grains of gunpowder to fight the Indians!
More information about the Techtalk
mailing list