[ILUG] Little code, please

Niall O Broin niall at linux.ie
Tue May 2 19:34:04 IST 2006


On 2 May 2006, at 18: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, so far we've had offers in perl, and a combo. of awk & shell,  
but for the life of me, unless there's something Tim hasn't told us  
(in which case presumably the other offers will also be wrong), I  
don't see why anything more than

grep -A 1 Tom FILE

is needed.



Niall




More information about the ILUG mailing list