-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rn grapenthin
committed
Jun 4, 2015
0 parents
commit 028c901
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# util |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |