#! /usr/bin/gawk -f # Last edited on 2000-10-12 20:44:46 by stolfi BEGIN { abort = -1; usage = ( ARGV[0] " [ -v inField=NUM ] < INFILE > OUTFILE" ); # Reads a list of records, and removes the ambiguity # in field `inField' by mapping each presumed / element # to /. if (inField == "") { inField = 1; } if (inField < 1) { arg_error("bad inField"); } } (abort >= 0) { exit abort; } /^[ ]*([#]|$)/ { print; next; } // { if (inField > NF) { data_error("too few fields"); } gsub(/ee/, "bh", $(inField)); print; next } function arg_error(msg) { printf "*** %s\n", msg > "/dev/stderr"; printf "usage: %s\n", usage > "/dev/stderr"; abort = 1; exit abort; } function data_error(msg) { printf "file %s, line %d: %s\n", FILENAME, FNR, msg > "/dev/stderr"; abort = 1; exit abort; }