#! /usr/bin/gawk -f # Last edited on 2001-01-02 02:28:16 by stolfi # Reads a file with records containing fields COUNT WORD. # Outputs the data in the format WORD(COUNT) WORD(COUNT).... BEGIN { if (wd == "") { wd = 60; } } /^[ ]*([#]|$)/ { next; } /./ { w = sprintf("%s(%d)", $2, $1); if (lin == "") { lin = w; } else if (length(lin) + length(w) + 1 > wd ) { print lin; lin = w; } else { lin = ( lin " " w ); } } END { if (lin != "") { print lin; } }