remove files with 0 size, space and double qoute

os=hpux11
shell=ksh

some jokers had written thousands of empty files into my $HOME. and the files are named inconsistently that some of them include space and double qoutes. all those files are of 0 size (when i did ls -al it told me so). the naming paterns are
like e.g of ls -al output:

being new to shell scripting i wrote this script:

#!/usr/bin/ksh
for i in `ls -al | awk '$5 < 1 {print $9}'`
do
  /usr/bin/rm $i
done

thank god that my attempt worked, but removed only the files whose name without space or double qoute. while the rest i am still cracking my little brain finding a way to deal with them.

any idea, pls.

i would apply different logic than yours:

#!/usr/bin/ksh
for i in `ls -a`
do
  FILESIZE=`ls -l $i|awk '{print $5}'`
  if [ $FILESIZE -eq 0 ]
  then
    /usr/bin/rm $i
  fi
done

this way rm will surely remove no matter how a file is named.

emmm...it was just a matter of programming logic huh. your idea worked just like what i desperately hope. thank you brother kanang and others too. i begin to like this forum. :slight_smile:

You might want to set up a cron job to run and collect user's history files and copy them to an inconspicuous directory.

Or go the $HOME directory and try to grep each user's history file for commands that you suspect were used.

This is part of being an admin. You need to find out who did this and report it if necessary. or at least document it for future ammunition.

Any user that would do this will soon try to breach root on your box. Count on it!

:slight_smile: