Shell Database Management (?)
David Johnson x4-6506
davej at mrsvr.UUCP
Fri Sep 1 02:31:30 AEST 1989
>From article <10596 at dasys1.UUCP>, by parsnips at dasys1.UUCP (David Parsons):
> The problem... the database consists of addresses... positions 99 and 100
> in each record contain a two-position abbreviation for the state. It's easy
> to get cut to read those two characters, and grep to identify the state I
> want to extract, but how the ^#$&! do you then copy the ENTIRE record
> thus identified to another file??? Using grep alone is no good because
> the abbreviation appears in various other places in the record...
>
> David Parsons
> Big Electric Cat Public UNIX
I tried e-mail and it bounced and bounced and . . .
Assume your "database" (file) is called database.
Assume your state abbreviation is in a shell vbl called $abbr
Try this:
cut -c99,100 database | grep -n "$abbr" | sed 's/:..*$/p/' | ed - foo
This should print all of the matching lines on stdout.
Good Luck.
--
David J. Johnson - Computer People Unlimited, Inc. @ GE Medical Systems
gemed!python!davej at crd.ge.com - OR - sun!sunbird!gemed!python!davej
"What a terrible thing it is to lose one's mind." - Dan Quayle
More information about the Comp.unix.questions
mailing list