#!/bin/sh # repeated -- Print any repeated words in a text file, such as "the the." # # BUGS: This will not catch repeated words where one is capatilized and the # other is not capitalized. # # AUTHOR: Gary T. Leavens repeated() { USAGE="Usage: $0 file ..." # no arguments? if test $# -eq 0 then echo "$USAGE" >&2 exit 1 fi awk 'BEGIN { prev = "" } { for (i=1; i<=NF; i++) { if (prev == $i) { if (prev ~ /[a-zA-Z]/) print $i, $i } prev = $i } } ' $* } [ -n "$echo" ] && set -x repeated $*