Wandering Thoughts archives

2006-04-11

A little script: howmany

There's a lot of Unix idioms that I use often enough to have turned into little shell scripts. Here's the first of them; I call it howmany:

#!/bin/sh
trap '' 13
sort "$@" | uniq -c | sort -nr

(The trap is necessary because of a Linux bash issue.)

Howmany does what its name says: it counts up how many times each line of its standard input appears, then shows them from most to least frequent with the count. It usually gets used at the end of pipelines that crunch logs and the like.

sysadmin/LittleScriptsI written at 01:29:49;


Page tools: See As Normal.
Search:
Login: Password:

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.