Suppose I have a file of five lines with IP addresses:
1.2.3.4
5.6.7.8
5.6.7.8
9.9.9.9
5.6.7.8
I need to find the average number of times every IP is repeated consecutively. In this example, every sequence of the same IPs has the length of 1, except for 5.6.7.8, which is repeated twice. So, for this example the answer is (1 + 2 + 1 + 1) / 4 = 1.25.
I'm trying to figure out how many times on average the users clicked the download button on my website before either giving up or realising that they should react to Firefox addon installation warning above the page.
Can this be done in a command line or I have to write a script to do it? I'm fine with writing a ruby script for it but I wonder if it can be done with a smart oneliner.