Lowercase to Uppercase of character in Shell Scripting [duplicate] Lowercase to Uppercase of character in Shell Scripting [duplicate] unix unix

Lowercase to Uppercase of character in Shell Scripting [duplicate]


There are many ways to define "beginning of a name". This method chooses any letter after a word boundary and transforms it to upper case. As a side effect, this will also work with names such as "Sue Ellen", or "Billy-Bob".

echo "james,adam,john" | perl -pe 's/(\b\pL)/\U$1/g'


With Perl:

echo "james,adam,john" | \  perl -ne 'print  join(",", map{ ucfirst } split(/,/))'


You can use awk like this to capitalize first letter of every word in your input:

echo "james,adam,john" | awk 'BEGIN { RS=","; FS=""; ORS=","; OFS=""; }{ $1=toupper($1); print $0; }'

OUTPUT

James,Adam,John