I have a file that contains something like the following:
red dog red cat red bird red horse blue hamster blue monkey blue lion pink pony pink whale pink pig pink dolphin
I need to increment a counter for every color, and then for every animal. So red would be 1, blue 2, pink 3. Next, dog, cat, bird, and horse would be 1, 2, 3, and 4. I need hamster to begin at 1 again because we are starting a new color.
If I do a "while read color animal" of said file, what can I do to compare when color is no longer equal to the previous color?
I am looking for something like this:
1.1 1.2 1.3 1.4 2.1 2.2 2.3 3.1 3.2 3.3 3.4
Any suggestions would be greatly appreciated :)