Sed is a useful tool for editing strings on the command line. Changing characters to uppercase or lowercase can be done easily with this tool by simply adding one or more of the following to your substitution string:

* \L – convert all proceeding characters to lowercase
* \U – convert all proceeding characters to uppercase
* \E – leave all proceeding characters in their current case

For example:

First letter capitalized:
echo "aBcDe fGh" | sed 's/^./\U&\E/'
will print ABcDe fGh

First word capitalized:
echo "aBcDe fGh" | sed 's/^[^ ]*/\U&\E/'
will print ABCDE fGh

Whole string lower case:
echo "aBcDe fGh" | sed 's/./\L&/g'
will print abcde fgh

  1. Lukas says:

    Awesome tutorial. Thank you very much!

  2. Harshil Shah says:

    How to convert 5th column to lower case in comma delimited file

  3. Linda says:

    thanz for this tutorial

  4. Linda says:

    How can i convert all lower into upper case in particular filw can u pls tell?