Urgent.!!! Multiple if within while loop ksh

Hi All,

I'm trying to write while loop with multiple if conditions. Each and every if condition with different variables. whenever one if condition fails i have remove the file
from filename and have to pick another file and loop should exit until the last file found in filename. Please help how to write a ksh shell script for that. Below i have given code what i tried

Thanks in advance.!!!

example:
#### here filename contain XXXX_YYYY_ZZZZ_DDD.txt as example
while read filename
#splitting a file without extension
full_filename=$filename
noextension=${full_filename%.*}
extension="${full_filename##*.}"

####assigning a patterns to different variable

echo "$noextension"|awk -F'_' '{ print NF-1 }' > countpattern

##### First fi######
if [ "$countpattern" -eq 5 ] ; then
A=$(echo $noextension|cut -d'_' -f1)
B=$(echo $noextension|cut -d'_' -f2)
C=$(echo $noextension|cut -d'_' -f3)
D=$(echo $noextension|cut -d'_' -f4)
E=$(echo $noextension|cut -d'_' -f5)
fi

####Second If########
if [ ! $extension=txt-a $A=HELP] || [ ! $extension=csv -a ! A =HELP ]
then
UPDATE TABLE ########################
rm full_filename
fi

####third if#####
if [ ! $C = "WE" ]
then
UPDATE TABLE ########################
rm full_filename
fi

Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

If you have posted a question in the regular forum with a subject "Urgent" "Emergency" or similar idea, we will, more-than-likely, close your thread and post this reply, redirecting you to the proper forum.

Of course, you can always post a descriptive subject text, remove words like "Urgent" etc. (from your subject and post) and post in the regular forums at any time.

Thank you.

The UNIX and Linux Forums

One way to break a huge logic statement like that into several smaller ones is:

while read filename
do
        REMOVE=0

        if [ ! condition1 ]
        then
                REMOVE=1
        fi


        if [ ! condition2 ]
        then
                REMOVE=1
        fi


        if [ ! condition3 ]
        then
                REMOVE=1
        fi

        if [ "$REMOVE" -eq 1 ]
        then
                remove_filename
        fi
done