Capitalize letters on bash shell script

It's easy just use the tr command to lower, upper or capital case. Here is an example and more info in TLDP

    function toCapital
       for x in $*
          echo -n ${x:0:1} | tr '[a-z]' '[A-Z]' | xargs echo -n
          echo -n ${x:1} | tr '[A-Z]' '[a-z]' | xargs echo -n
          echo -n " "

To test the function just call it:

    toCapital yuCa aMigo

The output is:

Yuca Amigo

Hope it's useful.

Updated: 2010/11/04


Chief Solution Architect (CSA) working at Daycohost.

Passionate about open source and cloud native solutions.


# Repos Pushed