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] Little code, please

[ILUG] Little code, please

Brian Foster blf at blf.utvinternet.ie
Tue May 2 19:54:17 IST 2006


  | From: nexor <nexor at fnet.pl>
  | Date: Tue, 2 May 2006 18:45:36 -0500
  | 
  | On Tuesday 02 May 2006 12:25, Timothy Murphy wrote:
  | > Talking of scripts, could you please tell me
  | > the simplest script to search through "refer-like" files
  | > with items separated by a blank line, eg
  | >
  | > %n Tom
  | > %t 3
  | >
  | > %n Peter
  | > %t 17
  | >
  | > I'd like a script (in any known language), say "foo", so that
  | > "foo Tom" would print out
  | >
  | > %n Tom
  | > %t 3
  | 
  | Well... you've asked for something simple  [ ... ]
  | Contents of foo.pl:
  |[... c.13 lines of incomprehensible perl(1) gibberish deleted... ]

 oh for something's sake, this is a trivial one-liner
 (for the example input and output shown):

   gawk  'BEGIN { RS = "" } $1 == "%n" && $2 == "Tom" { print }'

 parameterisation of the "Tom" is left as an exercise to
 the reader.  it can also be shorter (another exercise
 left to the reader).

 (in fact, I _thought_ something like this was one of the
 examples in the gawk(1) man page, but I cannot find it.)

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



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