Joining Textlines containing "Key: Text."

Steven Augart augart at h-sc1.UUCP
Sat Nov 9 03:36:12 AEST 1985


In article <2155 at umcp-cs.UUCP> chris at umcp-cs.UUCP (Chris Torek) writes:
>Sounds like a problem for `awk'.  
Yes, but this script isn't quite what's required...
Here's what I wrote for it ...
awk '{ if ($1 != lastfield) { if (lastfield != "") printf "\n"; printf "%s :", lastfield = $1 } printf " %s", $3 } END {print}' <yourfilename>
This will write the requested output to stdout, and has the additional
advantage that you can't run out of memory, whereas an internal array
may overflow on a non-virtual-memory machine.
This assumes that the file format given (with a space around the colon
on both sides) is accurate.
-- 
Steven Augart
swa%tardis at harvard.harvard.edu



More information about the Comp.unix mailing list