Check file size and remove files

Hi,
Here we have a situation where we have to check the file size and if the file size is greater than 0 bytes then remove the files from the directory.
1)EdwTrxn 2)EdwPost 3)EdwTndr 4)EdwSls 5)EdwSlsRej 6)EdwTndrRej
Files will be created in the directory in the following manner.
If any of the Rej files (5.EdwSlsRej 6.EdwTndrRej) size is greater than 0 bytes then we have to delete remaining 4 files (1.EdwTrxn 2.EdwPost 3.EdwTndr 4.EdwSls ).Else if Rej files size is 0 bytes then We have to remove those 2 Rej files(5.EdwSlsRej 6.EdwTndrRej) from the directory.
Thanks

Something like this?

cd /directory/where/files/are/present
if [ -s EdwSlsRej -o -s EdwTndrRej ]; then
echo rm EdwPost EdwSls EdwTndr EdwTrxn
elif [ ! -s EdwSlsRej -a ! -s EdwTndrRej ]; then
echo rm EdwSlsRej EdwTndrRej
fi

This will delete the EdwPost EdwSls EdwTndr EdwTrxn files if any of EdwSlsRej or EdwTndrRej files are larger than 0 bytes, but delete EdwSlsRej and EdwTndrRej files if they *both* are 0 bytes. No action is taken in any other case.

N.B. Just remove the echo commands to actually delete the files.

Hi,

I am new here.I want to write a script with following conditions -

  1. I have files with name IF008*
  2. If size of the file IF008* is 84 bytes then move it to junk folder
  3. If size of the file IF008* is greater than 84 bytes then move it to tmp folder.

Please reply.
All ideas are appreciated.

A hint to get you started:

$ find dir/ -type f -name 'IF008*' -size 84c
$ find dir/ -type f -name 'IF008*' -size +84c

Send those into a loop or use -exec

you can combine the sizes together so there's no need to invoke 2 times

find dir/ -type f -name 'IF008*' \( -size 84c -o -size .........\)
find dir/ -type f -name 'IF008*' -size 84c -exec mv {}  junk/ \;
find dir/ -type f -name 'IF008*' -size +84c -exec mv {} tmp/ \;

-Devaraj Takhellambam