Calculate the p95 latency from a file of numbers using only shell tools.
AdvancedHands-onawk, sed, grep and jq one-liners
Answer
sort -n latencies.txt | awk '{a[NR]=$1} END {i=int(NR*0.95); if (i<1) i=1; print "p95=" a[i]}'
Key trick → Percentiles need sorted data. Index at NR*0.95 (nearest-rank method). The if keeps tiny datasets from indexing 0.
More on awk, sed, grep and jq one-liners
Print only the lines containing "ERROR" with 3 lines of context, and show line numbers.BeginnerSum the response sizes (field 10) in an Nginx access log and print the total in MB.BeginnerReplace `DEBUG` with `INFO` in a config file in place, keeping a backup.BeginnerExtract all unique email addresses from a file.BeginnerFrom `kubectl get pods -A -o json`, list pods that are not Running, as namespace/name/phase.IntermediatePrint the 3rd column of a CSV whose fields are separated by commas, skipping the header.Beginner