I have an awk script that will do what you want (I think).
Here is my test intput (test.input):
cook, chef, fireman
cook, chef, fireman
cook, chef, fireman
cook, chef, fireman
house, farm, road
My awk script (up.awk):
# from: http://www.gnu.org/software/gawk/manual/html_node/Join-Function.html
function join(array, start, end, sep, result, i){
if (sep == "")
sep = " "
else if (sep == SUBSEP) # magic value
sep = ""
result = array[start]
for (i = start + 1; i <= end; i++)
result = result sep array[i]
return result
}
BEGIN {
FS="\n";
}
{
# split input on newline
for(i=1;i<=NF;i++) {
# split line on the commas
size = split($i, s, ",")
for(ii=1;ii<=size;ii++) {
# trim whitespace
gsub(/[[:space:]]*/,"",s[ii])
# uppercase first char and glue it back together
s[ii] = toupper(substr(s[ii], 0, 1)) substr(s[ii], 2)
}
# join array back and print it out
print join(s, 1, size, ", ")
}
}
How I run the script:
awk -f up.awk test.input >test.output
The output in my test.output:
Cook, Chef, Fireman
Cook, Chef, Fireman
Cook, Chef, Fireman
Cook, Chef, Fireman
House, Farm, Road