On 5/2/06, Timothy Murphy <tim at birdsnest.maths.tcd.ie> 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
I vote for awk
#!/bin/sh
cat text.txt |awk " \$2==\"$1\" {print \$4}" RS="\n\n"
that works in gawk - not sure about other awks.
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!