deleting empty files in a directory

Hello Gurus,

I want to delete only empty files (files with 0 bytes) at once from the local directory. Rightnow I need to go through all the files one by one manually and check the empty files before deleting them. Is there any unix command that finds and deletes empty files in a directory? Thanks in advance!

Try this (carefully, not tested):

for file in *; do
  if [[ ! -s $file ]]; then
    rm $file
  fi
done

this should be safer:

for file in *
do
  if [ ! -s "$file" ] ;  then
    ls -l "$file"
    rm -i "$file"
  fi
done

How about 'find' and 'xargs'?

find . -name "*" -size 0k |xargs rm

Thanks a lot Mark Thomas, milhan and Glenn Arndt for your good solutions, it worked for me. Have a great weekend!

# Only the current directory
find ./* -prune -type f -size 0 -exec rm {} \;
# The current directory and all subdirectories as well
find . -type f -size 0 -exec rm {} \;