On 7/28/05, Paul Jakma <paul at clubi.ie> wrote:
> On Thu, 28 Jul 2005, Brian Foster wrote:
>> > possible confusion/unclarity in Paul's request. it looks to me
> > that Paul's script will _only_ print matches when word1 is at
> > the end of a line and word2 is at the start of the next line.
>> No wait.. that *is* exactly what PB asked for, I quoted his request
> before my awk suggestion:
My fault, apologies, I should have made it much clearer. What I was
looking for was a way to make grep treat newlines as spaces, and so
treat flowed paragraphs in a pleasant manner. I asked how to match two
words, split across a new line, but what I really should have asked
for is how to match N words in a phrase or sentence, where they may be
split over 1, or possibly more lines.
In other words, I wanted to do 'grep "I quoted his request before my
awk suggestion"' and get back the two lines above. A way to do this
with grep, rather than emulating it with awk, sed or perl, would be
best, as its then easy to use some of the fancyness like -n,
--color=auto, or -A 1 -B 1.
Thanks to all who replied.
Paul
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!