summaryrefslogtreecommitdiff
path: root/scripts/find_repeated_words.sh
blob: cca6964f44ff236d7863118c6fde692bc08abbdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
#
# A simple script for finding instances of repeated consecutive words
# in manual pages -- human inspection can then determine if these
# are real errors in the text.
#
# Usage: sh find_repeated_words.sh [file...]
#

for file in "$@" ; do 
    words=$(MANWIDTH=2000 man -l "$file" 2> /dev/null | col -b | \
	tr ' \008' '\012' | sed -e '/^$/d' | \
	sed 's/ *$//' | 
	awk 'BEGIN {p=""} {if (p==$0) print p; p=$0}' | \
	grep '[a-zA-Z]' | tr '\012' ' ')
    if test -n "$words"; then
        echo "$file: $words"
    fi
done