Find the durations and their average between the dataset in an interval in shell script
问题 This is related to my older question Find the durations and their maximum between the dataset in an interval in shell script I have a dataset as: ifile.txt 2 3 2 3 2 20 2 0 2 0 0 2 1 2 5 6 7 0 3 0 3 4 5 I would like to find out different duration and their average between the 0 values in 6 values interval. My desire output is: ofile.txt 6 5.33 1 2 1 2 1 2 5 4.2 1 3 3 4 Where 6 is the number of counts until next 0 within 6 values (i.e. 2,3,2,3,2,20) and 5.33 is the average value among them; 1