-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcapitalize_all_words.awk
More file actions
46 lines (43 loc) · 906 Bytes
/
capitalize_all_words.awk
File metadata and controls
46 lines (43 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/awk -f
#
# script that capitalizes all words. at the same time sets all other characters of the
# words to lowercase.
#
# uwe.geercken@datamelt.com
# http://datamelt.com
#
# last update: 2009-05-11
#
#
function capitalizeWords(textstring)
{
# we assume that the text string is seperated by spaces
split(textstring,words," ");
newstring=""
# loop over the members of the array
for ( item in words )
{
# we capitalize the first letter of the word and then add the rest
# of the word in lowercase
newWord= toupper(substr(words[item],1,1)) tolower(substr(words[item],2))
newstring=newstring " " newWord;
}
return newstring;
}
BEGIN {
OFS=FS=";";
}
{
split(exceptions,exc,",");
# loop over all fields/columns of the input stream
for(i=1;i<=NF;i++)
{
result=exc[i];
print "xxx: " result;
if(result=="")
{
$i=capitalizeWords($i);
}
}
print;
}