I have a text file called file.txt that has below entries :-
healthy
healthy
healthy
healthy
healthy
unhealthy
initial
healthy
initial
healthy
Now i do a count of the number of healthy , initial and unhealthy in this file using below command :-
grep -c healthy file.txt
grep -c unhealthy file.txt
grep -c initial file.txt
Now i want a loop condition in shell script that does this for me :-
while [ $(grep -c "healthy" file.txt) -lt 6 -a $(grep -c "unhealthy" file.txt) != 0 -a $(grep -c "initial" file.txt) != 0 ]
do
bla bla bla
done
Basically all i am trying to do is that for this dynamic file whose entries will keep changing as part of some other script, i want a loop to happen as long as count of healthy in the file is less than equal to 6 and also count of unhealthy is anything above 0 and also count of initial is anything above 0, then do something else exit out of the loop. I am not getting the syntax right. Any help here would be greatly appreciated.