#! /bin/awk -f # # bsort --- put fields of a refer file into a standard order # see wsort ... # needs to take care of continuation fields!!! # can a single script handled different kinds of files # and different orders of fields? # add here as necessary ... /^%[LTAP]/ { fld[$1] = sprintf "%s%s\n", fld[$1], $0 next } /./ { etc = sprintf "%s%s\n", etc, $0 next } /^$/ { printf "%s", fld["%L"] printf "%s", fld["%A"] printf "%s", fld["%T"] printf "%s", etc printf "%s", fld["%P"] etc = fld["%A"] = fld["%T"] = fld["%P"] = fld["%L"] = "" printf "\n" }