bin/freqs @ d9ee2c4aa85b

More shell scripts, etc
author Steve Losh <steve@stevelosh.com>
date Sun, 26 Jan 2020 17:32:44 -0500
parents a81cac75b4d3
children (none)
#!/usr/bin/env bash

set -euo pipefail

function usage {
    echo "freqs - display frequencies of the unique lines of stdin

USAGE: $0 [OPTIONS]

Options:
  -h, --help    display this help text and exit
"
}

function die {
    echo "$0: $1" >&2;
    exit 1
}

OPTS=$(getopt --options h --long help --name "$0" -- "$@")
eval set -- "$OPTS"

while test "$#" -gt 0; do
    case "$1" in
        -h | --help ) usage; exit 0;;
        -- ) shift; if test "$#" -ne 0; then die "unrecognized arguments: $*"; fi ;;
        * ) die "unrecognized arguments: $*" ;;
    esac
done

awk '{ c[$0]++ } END { for (l in c) print c[l], l }'