Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rn grapenthin committed Jun 4, 2015
0 parents commit 028c901
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# util
38 changes: 38 additions & 0 deletions check_repeats
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/tcsh
# (use sh2doc.pl to auto generate HTML doc)
#
##BRIEF
# check textfile for repeated words using grep
#
##AUTHOR
# Ronni Grapenthin
#
##DATE
# version 2011-01-27
#
##DETAILS
# check textfile for repeated words using grep
# (regexp partly blatantly stolen off the web: http://www.codeproject.com/kb/dotnet/RegexTutorial.aspx?fid=136362&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=226)
# gives line number and marks repeated words, doesn't care about cases
#
# USAGE:
#
# usage: check_repeats <text-file>
#
##CHANGELOG
# 2010-06-13, ronni: First version.
# 2011-01-27, ronni: added checking over linebreaks, apparently this should be
# possible and easier using sed; couldn't get it to work though
# I iterate over the file again, that's inefficient, but the output
# might be clearer.

echo "Checking for repeated words in a line of ${1}:"
grep -Ein --color "\b(\w+)\b\s*\1\b" $1
echo " "

echo "Checking for repeated words over linebreaks of ${1}:"
awk 'BEGIN{getline l;} {combined=l " " $0; printf(" %.5d - %.5d: %s\n",FNR,FNR+1, combined); l=$0;}' $1 | grep -Ei --color "\b(\w+)\b\s*\1\b"
echo " "
echo "Done."

#thank you very much!

0 comments on commit 028c901

Please sign in to comment.