http://phecoopwm6x7azx26ctuqcp6673bbqkrqfeoiz2wwk36sady5tqbdpqd.onion/posts/bash/generating-average-related-stats-with-awk.html
Input should be pre-sorted awk '{all[NR] = $0} END{print all[int(NR*0.5 - 0.5)]}' Usage Example # Calculate average based on the 4th column in a tab seperate-file cat file.csv | awk -F '\t' 'BEGIN{t=0}{t=t+$4}END{print t/NR}' # same as above, but 95th percentile cat file.csv | sort -n -t \t -k4 | awk '{all[NR] = $4} END{print all[int(NR*0.95 - 0.5)]}' # Calculate the media, but assume it's comma-seperated this time and use column 2 cat file.csv | sort -n -t, -k2 | awk...