Path: utzoo!attcan!uunet!cs.utexas.edu!usc!ucsd!ucsdhub!hp-sdd!hplabs!hp-ses!hpcuhb!hpda!hpcuhc!selmer From: selmer@hpcuhc.HP.COM (Steve Elmer) Newsgroups: comp.misc Subject: AWK scripts anyone? Message-ID: <1220001@hpcuhc.HP.COM> Date: 21 Feb 90 00:58:18 GMT Organization: Hewlett Packard, Cupertino Lines: 39 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!@#$%^&*()_-+=|\}{[]:;?/.,<>"); }