Results 1 to 5 of 5
in a huge text
we want all of the
:tho becomes you
thou becomes you
thy becomes your
thine becomes your
and we should change Tho to You
also
the ...
- 07-01-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 16
AWK script replacing words in a text
in a huge text
we want all of the
:tho becomes you
thou becomes you
thy becomes your
thine becomes your
and we should change Tho to You
also
the case that tho with a punctuation such tho, should be you,
basically i writer down something like this
awk '
{
for(i=1;i<=NF;i++)
{
if (($i == "thee")||($i == "thou"))
{
printf("you")
}
else if (($i == "Thee")||($i == "Thou"))
{
printf("You")
}
else
{
printf $i
}
printf " "
}
print ""
}'
There are two problems :
one is that it doesn't work fine with punctuation
second is that after the job done, it will leave a extra blank at the end of each line.
- 07-01-2010 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
perhaps the stream editor "sed" is better suited for this
if "text" is the name of your long text, then something like this
might work:
sed 's/thee/you/;s/thou/you/;s/Thee/You/;s/Thou/you/' <text
this does what your "awk" script doesthe sun is new every day (heraclitus)
- 07-01-2010 #3Just Joined!
- Join Date
- Jun 2010
- Posts
- 16
Thx but the queestion asks me to make a awk script
- 07-01-2010 #4
- 07-01-2010 #5Just Joined!
- Join Date
- Jun 2010
- Posts
- 16
want the get idea.
how this would work
$i == thou[
unct:]?
$i == "thou," | "thou." | "thou" etc etc


Reply With Quote
