# HG changeset patch # User Steve Losh # Date 1579840507 18000 # Node ID a81cac75b4d398077d1a1cb89c3e9751c6d956e9 # Parent 39c693929f1bc9b94de82874a83d27d632df2a03 freqs and props diff -r 39c693929f1b -r a81cac75b4d3 bin/freqs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/freqs Thu Jan 23 23:35:07 2020 -0500 @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euo pipefail + +awk '{ c[$0]++ } END { for (l in c) print c[l], l }' diff -r 39c693929f1b -r a81cac75b4d3 bin/props --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/props Thu Jan 23 23:35:07 2020 -0500 @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -euo pipefail + +OPTS=$(getopt --options hd:pP --long help,decimals:,percent,no-percent -n "$0" -- "$@") +eval set -- "$OPTS" + +DECIMALS='5' +MUL='1.0' + +while true; do + case "$1" in + -h | --help ) + echo "USAGE: $0 [-h|--help] [-n N | --decimals N] [--percent | --no-percent]" + exit 0 ;; + -d | --decimals ) DECIMALS="$2"; shift 2 ;; + -p | --percent ) MUL='100.0'; shift ;; + -P | --no-percent ) MUL='1.0'; shift ;; + -- ) shift; break ;; + * ) break ;; + esac +done + +awk ' + { c[$0]++ } +END { for (l in c) printf("%.'"$DECIMALS"'f %s\n", c[l] / NR * '"$MUL"', l) } +'