Case Transformation in Bash and POSIX with Examples

How to uppercase, lowercase, and capitalize

Shinichi Okada
mkdir Awesome

--

Photo by Alexander Andrews on Unsplash

Bash

Use ^ to convert the first letter to uppercase and ^^ to convert all characters to uppercase.

Use , to convert the first letter to lowercase and ,, to convert all characters to lowercase.

Use ~ to toggles the case for the first character and ~~ to toggle cases for all characters.

Try the following examples.

In Bash, you can do it in a different way:

You can use converting the first letter with the read command to get the user’s response:

--

--

Shinichi Okada
mkdir Awesome

A programmer and technology enthusiast with a passion for sharing my knowledge and experience. https://codewithshin.com