Bootstrap FreeKB - Bash (Scripting) - uppercase or lowercase (tr command)
Bash (Scripting) - uppercase or lowercase (tr command)

Updated:   |  Bash (Scripting) articles

The tr (translate) command can be used to modify a string to be lowercase or uppercase. In this example, the string is modified to be lowercase.

~]# echo "Hello World" | tr '[:upper:]' '[:lower:]'
hello world

 

In this example, the string is modified to be uppercase.

~]# echo "Hello World" | tr '[:lower:]' '[:upper:]'
HELLO WORLD

 

In this example, a variable in a bash script is modified to be lowercase.

foo="Hello World"
foo=$(echo $foo | tr '[:upper:]' '[:lower:]')

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 019f4c in the box below so that we can be sure you are a human.