| Date: Wed, 27 Jul 2005 21:19:24 +0000
| From: Paul Biggar <paul.biggar at gmail.com>
|
| [ ... ] Does anybody know a way of making this return a case where
| word1 is at the end of one line, and word2 is at the start of the
| next.
just as I was crawling into bed, what may be a
better, albeit longer (and rather more cryptic),
solution occurred to me:
sed -n -e '{:b;/word1[[:space:]]*$/{N;bb;}}' -e '/word1[[:space:]\n]\+word2/p'
unlike the previous gawk(1) solution, that prints
just the matching line(s), and does not care how
yer paragraphs are written. actually, it prints
one line too many in the obscure case:
line one ends with word1
word2 starts line two also ends word1
line three but no 2nd word
in any case, it should work with any modern sed(1);
i.e., any `sed' that supports EREs.
cheers!
-blf-
--
Experienced (20+ yrs) kernel/software Eng: | Brian Foster Montpellier,
• Unix, embedded, &tc; • Linux; • doc; | blf at utvinternet.ie FRANCE
• IDL, automated testing, process, &tc. | Stop E$$o (ExxonMobile)!
Résumé (CV) http://www.blf.utvinternet.ie | http://www.stopesso.com
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!