URI:
       tnum.collapse - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tnum.collapse (608B)
       ---
            1 awk ' # num.collapse
            2 #   Input:  lines of form: string (tab) num1 [(space) num2]
            3 #   Output: lines of form: string (tab) fancy.num.list
            4 #
            5 #   fancy.num.list contains items, separated by ", ", of form: num or num-num
            6 #        Sequence of input lines with same value of string is combined
            7 #        into a single output line.  Each input line contributes either
            8 #        num or num-num to output line.
            9 
           10 BEGIN        { FS = OFS = "\t" }
           11 
           12         { sub(/ /, "\\(en", $2) }  # use - if there is no en dash
           13 
           14 $1 != p        { p = $1
           15           if (NR > 1) printf "\n"
           16           printf "%s\t%s", $1, $2
           17           next
           18         }
           19         { printf ", %s", $2 }
           20 END        { if (NR > 0) printf "\n" }
           21 ' $*