ATTN: AWK GURUS!!! (lower to upper conversion)

Barry Shein bzs at bu-cs.BU.EDU
Tue Mar 22 16:58:55 AEST 1988



>	Convert possibly mixed-case strings to upper-case.
>	(not counting case-less chars like digits)

The attached works under 4.3bsd as you required.

	-Barry Shein, Boston University

BEGIN {
  upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  lower = "abcdefghijklmnopqrstuvwxyz";
}  
{
  out = "";
  for(i=1;i <= length($1);i++) {
    if((cpos = index(lower,c = substr($1,i,1))) > 0)
      c = substr(upper,cpos,1);
    out = out c;
  }
  print out;
}



More information about the Comp.unix.questions mailing list