У меня есть скрипт awk, который будет делать то, что вы хотите (я думаю).
Вот мой тестовый ввод (test.input):
cook, chef, fireman
cook, chef, fireman
cook, chef, fireman
cook, chef, fireman
house, farm, road
Мой скрипт awk (вверх.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, ", ")
}
}
Как запустить скрипт: awk -f up.awk test.input >test.output
Вывод в моем test.output:
Cook, Chef, Fireman
Cook, Chef, Fireman
Cook, Chef, Fireman
Cook, Chef, Fireman
House, Farm, Road