More
author |
Steve Losh <steve@stevelosh.com> |
date |
Tue, 09 Apr 2024 09:20:04 -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 }'