#!/bin/sh ## Output words in order of frequency (with counts) in merge of given files ## SYS V /usr/bin/tr and BSD /usr/ucb/tr treat strings differently. ## You could use just plain tr instead of /usr/ucb/tr by uncommenting: # PATH=/usr/ucb:/usr/bin cat "$@" | ## concatenate all given input files /usr/ucb/tr 'A-Z' 'a-z' | ## lower case words /usr/ucb/tr -cs 'a-z' '\012' | ## -c: complement string 1 ## -s: suppress repeated characters of string 2 ## In Sys V, string 2 is not automatically padded out unless use [x*] notation ## and ranges are specified as [a-z] although a-z also works. Thus: ## /usr/bin/tr -cs '[a-z]' '[\n*]' ## Many versions of tr now allow specifications of type ## [:alpha:] for a-zA-Z, [:upper:] for A-Z, [:lower:] for a-z etc. sort | uniq -c | ## replace n copies of 'line' with: n line sort -nr ## -n : numerical sort on 1st column -r: reverse order