Suppose I have a file of five lines with IP addresses:
22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11
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 18.104.22.168, 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.