Skip to content

Instantly share code, notes, and snippets.

@hashbrowncipher
Created October 7, 2016 18:02
Show Gist options
  • Save hashbrowncipher/22f39d6c9dcb6b8a0070d8f5e793cdfa to your computer and use it in GitHub Desktop.
Save hashbrowncipher/22f39d6c9dcb6b8a0070d8f5e793cdfa to your computer and use it in GitHub Desktop.
#!/bin/bash
chrt -p -i 0 $$
file="$1"
field="$2"
lines=$(awk -v field=$field '$field ~ /[0-9][0-9.]*/ { count++ } END { print count }' "$file")
sort -k$field -nr "$file" | awk -v lines=$lines '
NR==1 ||
NR==int(lines * 0.00001) ||
NR==int(lines * 0.0001) ||
NR==int(lines * 0.001) ||
0 == NR % int(lines * 0.01)
' "$file" | \
paste - <(
echo "max"
echo "p99999"
echo "p9999"
echo "p999"
for i in p{99..01}; do echo $i; done;
echo "min"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment