[comp.misc] AWK scripts anyone?

selmer@hpcuhc.HP.COM (Steve Elmer) (02/21/90)

I have an interest in scripts written for the AWK program.  I recently had to
figure out how to make it upper/lower case a variable and would have preferred
to find out from notes.  Is there a notes group that applies?

Well, if you got this far you might :-) be interested:

-----------------------cut here----------------------------------------------
BEGIN { plower = "[abcdefghijklmnopqrstuvwxyz]";
        pupper = "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]";
        lower = "abcdefghijklmnopqrstuvwxyz";
        upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      }

function toupper(s, t, i, c) {
  i = 1
  t = "";
  while ((c = substr(s, i++, 1)) != "")
    if (c ~ plower)
      t = t substr(upper, index(lower, c), 1);
    else
      t = t c;
  return t;
  }

function tolower(s, t, i, c) {
  i = 1
  t = "";
  while ((c = substr(s, i++, 1)) != "")
    if (c ~ pupper)
      t = t substr(lower, index(upper, c), 1);
    else
      t = t c;
  return t;
  }

END {
      printf "'%s'\n", toupper("abcDEF!@#$%^&*()_-+=|\}{[]:;?/.,<>");
      printf "'%s'\n", tolower("abcDEF!@#$%^&*()_-+=|\}{[]:;?/.,<>");
    }

stevens@hsi.UUCP (Richard Stevens) (02/24/90)

The latest version of nawk from the Toolchest (cost is $300, I think)
now supports a toupper() and tolower() function.  The GNU awk, gawk,
also supports these two functions.

With the general availability of these latest versions of awk,
and their low price (essentially free for gawk), there's no
reason to be running the ancient versions from V7 days.

	Richard Stevens
	Health Systems International, New Haven, CT
	   stevens@hsi.com
           ... { uunet | yale } ! hsi ! stevens