bin/freqs @ 13ec2c64c7a6

More
author Steve Losh <steve@stevelosh.com>
date Wed, 17 Jun 2020 12:29:36 -0400
parents d9ee2c4aa85b
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 }'