Guest_imported
New member
- Jan 1, 1970
- 0
The following script matches a pattern specified on the command line (e.g. gawk -f file.awk pattern="the" test.txt):
$0~pattern{
gsub(pattern, "|&|",)
print $0
}
it matches sentences like:
John is the greatest.
He's up there.
and turns this into:
John is |the| greatest.
He's up |the|re.
But in fact, I only wish it to match the first sentence (John is |the| greatest.) Can someone tell me what I should add to my script so that only the word "the" will be found and not a sequence of 't' 'h' 'e' in words like "there", "them", "ether", etc. ?
Thanks
$0~pattern{
gsub(pattern, "|&|",)
print $0
}
it matches sentences like:
John is the greatest.
He's up there.
and turns this into:
John is |the| greatest.
He's up |the|re.
But in fact, I only wish it to match the first sentence (John is |the| greatest.) Can someone tell me what I should add to my script so that only the word "the" will be found and not a sequence of 't' 'h' 'e' in words like "there", "them", "ether", etc. ?
Thanks