Last active
April 25, 2017 10:32
-
-
Save romank0/13d4b951a69be048af10481d476bd6f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# stdin should be integers, one per line. | |
# command line perncentiles e.g. 75 90 95 | |
percentiles=$* | |
tmp="$(mktemp -t percentileXXXX)" | |
total=$(sort -n | tee "$tmp" | wc -l) | |
for percentile in $percentiles | |
do | |
count=$(((total * percentile + 99) / 100)) | |
echo "$percentile: $(head -n $count "$tmp" | tail -n 1)" | |
done | |
rm "$tmp" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment