UNIX Programming, Certification, System Administration, Performance Tuning Reference Books
Logic in possible in Scripts

I have a major doubt in scripts i.i
if [ $MEET = '0' ]
then echo " SENT "
else
if [ $MEET = '8' ]
then echo "NOTSENT"
fi
fi
This gave me a output but still i have doubt like
EX: If i have four SENT
then output One SENT
If i have one NOTSENT among four SENT
then output One NOTSENT
this condition should be included along with the above one
is it possible
help me

---------------

Try this. It would help if you could post a sample of your data.
if [ "$MEET" -eq 0 ] ; then
echo "SENT"
elif [ "$MEET" -eq 8 ] ; then
echo "NOTSENT"
else
echo "ERROR"
fi

or

case $MEET in
0 ) echo "SENT" ;;
8 ) echo "NOTSENT" ;;
* ) echo "ERROR" ;;
esac

---------------

I don't want error to be displayed instead
if [ $MEET = '0' ]
when this condition is checked in a file.
file has $MEEt = 0 condition (5) times in a file
I want all condition to be checked but with a single output "SENT"
During the condition Check If any one of the
$MEET = '8'
It should be out of the loop to display "NOTSENT"
here no need of any ERROR
I want to know is there any possibility of using counter to check all the five condition and to display single output

---------------

Would that be 5 consecutive occurances of 0 ?
A sample of your data file would help us get you a better answer.

looping is pretty easy
i=0
while [ $i -lt 5 ] ; do
echo "insert code here"
done

Also you might use awk to bracket the area of the file you are looking at, then grep -c for a count

---------------

First,I should thank you so so much for your effort
Table file sample:
Yes, my file contains
..
..
Meet => 0
------------
..
..
Meet => 0
----------
sometimes
..
..
Meet=> 8
----------
..
..
Meet => 0
----------
..
..
Meet => 0
Like this Five condition in a file Table

My Script was:
for Meet in `grep "Meet" table | cut -d ">" -f2`;
do
echo $Meet
if [$Meet ='0']
then echo "Sent" >> file1
else
if [ $Meet ='8']
then echo "Notsent" >> file2
fi
fi
done
this produced an output for each condition of the file.
What i want is an Ultimate Output i.e
If all condition of file were "0"
output "Sent"
If any of the condition is "8" among 5 condition. come out of the check
Display "Notsent

---------------

if [ `grep Meet table | grep -c 0` -eq 5 ] ; then
echo "SENT" >> file1
else
echo "NOTSENT" >> file2
fi
or with awk

if [ `awk -F">" '/Meet/ { print $2 }' table |grep -c 0` -eq 5 ] ; then
echo "SENT" >> file1
else
echo "NOTSENT" >> file2
fi

---------------

try to make some changes in my script:
like my script reads the condition . Only problem is :IT PRODUCES DISPLAY - for each condition-

SENT,SENT,SENT,SENT,SENT(5 times) which i don't want.
I want is to READ all 5 condition & then display SENT(1 time)
If sometimes condition MEET => 8 ,it should come out of checking to display single output
"NOTSENT"
David is it possible to include counters in my script to check all condition & then display.
Sorry to trouble u much
By now you would have understood my problem

---------------

OK. So you didn't like working tested elegant answer #1 or working tested elegant answer #2.

Let's do it with a loop contruct.
This is ksh format. If you are using a differnt shell, you may need to do the incrementing differently.

count=0 ; rccount=0
for Meet in `grep "Meet" table | cut -d ">" -f2`;
do
if [$Meet ='0']
then
((rccount=rccount+1))
fi
((count=count+1))
done
if [ $rccount -lt 5 -a $count -eq 5 ] ; then
echo "Notsent" >> file2
else
echo "Sent" >> file1
fi

---------------

Thank you so much .This counter helped me lot. I used only one counter which checks the negative condition
it worked & produced a required result

---------------

Quick Links:
Do you have a UNIX Question?

Unix Home: Unix System Administration Hints and Tips