#!/bin/csh -f
# Finds doubled words in the files given as arguments.
# The output consists of all pairs of lines containing a doubled word,
# with the intervening carriage return replaced by a space.
# Any grep options may be used (and "-in" is suggested), but all options
# must appear in the first argument.
# The definition of word here is a maximal string composed of
# alphanumerics and underscores.  The two occurences of the doubled
# word can be separated only by white space; thus, for example,
# a word occuring as the last word of a sentence and the first word
# of the next will not be reported.

set opts
if ("$1" =~ -*) then
  set opts = $1
  shift
endif

grep2lp $opts '\<\([a-zA-Z0-9_]\{1,\}\)[ 	]\{1,\}\1\>' $argv[1-]
