2022-09-01 18:01:09 -07:00
|
|
|
#!/usr/bin/env sh
|
2024-03-26 15:08:14 -07:00
|
|
|
# YES_ZSH YES_BASH YES_DASH YES_ASH
|
2022-09-01 18:01:09 -07:00
|
|
|
|
|
|
|
### @ scount
|
2022-09-01 18:36:57 -07:00
|
|
|
### perform `sort | uniq -c | sort -n`, preferring GNU awk when available.
|
2022-09-01 18:01:09 -07:00
|
|
|
|
|
|
|
if "$HOME/sh/witch" gawk >/dev/null 2>/dev/null; then
|
|
|
|
scount() {
|
|
|
|
argc $# -le 1 scount || return
|
|
|
|
gawk -- 'BEGIN{PROCINFO["sorted_in"]="@val_num_desc"}{a[$0]--}END{for(i in a)printf "%7i %s\n",-a[i],i}' "$@"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scount() {
|
|
|
|
argc $# -le 1 scount || return
|
2022-09-01 18:36:57 -07:00
|
|
|
sort -- "$@" | uniq -c | sort -n
|
2022-09-01 18:01:09 -07:00
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -n "${preload+-}" ] || . ~/sh/preload || exit 2
|
|
|
|
eval ${preload:-preload} argc
|
|
|
|
[ -n "${preload+-}" ] || scount "$@"
|