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

Brian Foster blf at blf.utvinternet.ie
Sat Jul 30 10:02:31 IST 2005


  | Date: Thu, 28 Jul 2005 11:51:02 +0100
  | From: Darragh Bailey <felix at compsoc.nuigalway.ie>
  | 
  | On Wed, 27 Jul 2005, Paul Biggar wrote:
  | > Does anybody know a way of making [ grep ] return a case where
  | > word1 is at the end of one line [ followed by ] word2 [ at ]
  | > the start of the next.
  | 
  | I'm guessing that no-one tried
  |    cat file  |  grep -e "word1 word2" -e "word1
  |    word2"

 I'm guessing the above either  (1) wasn't tested  or
 (2) wasn't tested properly; and, maybe,  (3) TFM was
 not R.

 newlines are used to separate (E)REs in grep(1) with
 an (implied) OR; i.e., the above, due to the 2nd `-e'
 (the two newline-separated REs) prints all line(s)
 that contain either word1 OR word2.  and as such,
 the 1st `-e' is useless.  (so is the cat(1).)

 the above, using GNU grep(1) — I'm not sure the
 following re-writes work with other `grep's — is
 equivalent to either of the following:

    grep -e "word1 word2" -e "word1" -e "word2" FILE
    grep -e "word1" -e "word2" FILE

 test the original (or the rewrites) with text like:

    the 1st line has word1 only and not at end
    the 2nd line has word2 only and not at start

 and watch the tested version clearly not do what
 Paul wants.

 unfortunately, after a very_rapid_ read of both
 the GNU grep(1) man page and GNUs `info grep',
 I did not see this newline behaviour described
 (other than the `fgrep' (fixed string) variant).

cheers!
	-blf-

p.s.  my (admittedly vague) memory is multiple REs
      separated by newline (meaning OR) has worked
      in all(?) `grep's since 7th Edition.

-- 
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



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