Convert String from uppercase to lowercase in Bash


In this example, we take a look at how to convert an uppercase string to lowercase using a bash script.

Example:
#!/bin/bash

upper_case_str="CODE2CARE - LINE OF CODE FOR CHANGE"
lowercase_str=$(echo "$upper_case_str" | tr '[:upper:]' '[:lower:]')

echo "Uppercase String: $upper_case_str"
echo "Lowercase String: $lowercase_str"
Output:
Uppercase String: CODE2CARE - LINE OF CODE FOR CHANGE
Lowercase String: code2care - line of code for change
Bash Convert String from Uppercase to Lowercase Example

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap