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

The tr (trade) 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:])

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |