Skip to contentSkip to conversation

(Q)gawk sorting

DISCUSSION David Jackson 1 participant 1 message Jun 2, 2002

lore
Share & tools
lore
#0 lore raw

Howdy --
I could use a little help with gawk sort function.

Thanks in advance,
David

Here's an example record:

Axtral
130 Dartmouth St. Suite 415
boston, Massachusetts 02116

Here's what I'm looking for as far as output:

-------- Massachusetts --

Axtral
130 Dartmouth St. Suite 415
boston, Massachusetts 02116

.......
........

---- Colorado ----

......
......
......

Here is the gawk script so far:

#!/usr/bin/gawk -f
BEGIN {
FS="\n"
RS="\n\n"
OFS="\n"
}
{
split($3,CityState,",")
print $1,$2,CityState[1]", " CityState[2],$4,$5
}