LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] text flow tools

[ILUG] text flow tools

Darragh Bailey felix at compsoc.nuigalway.ie
Thu Jul 28 11:51:02 IST 2005


Quoting Brian Foster <blf at blf.utvinternet.ie>:

>   | Date: Wed, 27 Jul 2005 23:35:19 +0100 (IST)
>   | From: Paul Jakma <paul at clubi.ie>
>   | On Wed, 27 Jul 2005, Paul Biggar wrote:
>   | > grep can find two words one after the other by doing 'grep "word1
>   | > word2"'. 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.
>   |
>   | Using GNU AWK, something vaguely like (untested):  [ ... ]
>
>  I have not tried Paul's posted script, but it does point out a
>  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.
>  (it also does not allow trailing spaces at the end of line 1
>  or leading spaces on line 2, both of which are legal and
>  harmless in (La)TeX.)
>
>  but that is not how I read Paul's question.  I read it as wanting
>  to print something (nominally each line) that "matches", where a
>  match is word1, whitespace (including up to one newline), then
>  word2.  e.g., the single line â&#65533;&#65533;foo word1 word2
barâ&#65533;&#65533; would also
>  match â&#65533;&#65533; which is not printed by Paul's gawk(1) solution.
>
> cheers!
> 	-blf-

I'm guessing that no-one tried
cat file | grep -e "word1 word2" -e "word1
word2"


its a little tricky to get grep to match newlines but if you type the line
followed by return, if you haven't closed the quotes it is treated as a newline
character.
cat file | grep -e "word1 word2" -e "word1<return>
word2"


--
Darragh

"Nothing's foolproof to a sufficently talented fool"




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell