CamelCase in AWK
Example for versions
Jawk 1.02,
gawk 3.1.6,
mawk 1.3.3
mawk provides no function length
to get the size of the array, neither it can be used in Jawk — an attempt results in “Cannot evaluate an unindexed array.” runtime error.
Instead we can use the fact that function split
returns the number of string fragments it extracted from the string. Otherwise this example is identical to this one.
{ text = $0;
N = split(text, words, /[^a-zA-Z]+/);
for (i=1; i<=N; i++) {
res = res toupper(substr(words[i],1,1)) tolower(substr(words[i],2));
}
print res
}
Comments
]]>blog comments powered by Disqus
]]>