This is a little less gross, I hope (and it also seems to work). BEGIN { lower="abcdefghijklmnopqrstuvwxyz" upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ" } { new = "" for (i=1; i <= length; ++i) { cur = substr($0, i, 1) j = index(lower, cur) if (j != 0) new = new substr(upper, j, 1) else new = new cur } print new }