Count number of occurences of a character in a field defined by the character in another field

Hello,

I have a text file with n lines in the following format (9 column fields):

Example:
contig00012 149606 G C 49 68 60 18 c$cccccacccccccccc^c

I need to count the number of lower-case and upper-case occurences in column 9, respectively, of the character presented in the 4th column.

In my example line the question would be how many "C" and "c" is there in column 9 (c$cccccacccccccccc^c)? The answer would be "C"=0 and "c"=17

If possible characters proceded by a '^' (e.g. ^c) and characters followed by a '$' (e.g c$) should not be counted. So the answer will instead be "C"=0 and "c"=15

Thanks. :slight_smile:

Seems like a homework problem.

You have to follow rules to post homework.

please post your effort

Ok, this was my first post here and I have actually read the forum rules, so I would not post homework.
Anyway, I got past the problem now with help from other side.