View Single Post
V6Pony

 
V6Pony's Avatar
 
Member Since: Oct 30, 2010
Location: Southern Illinois
Posts: 270
V6Pony is an unknown at this point
Mac Specs: MBP 15" I7 first one and loving it.

V6Pony is offline
#!/bin/bash
echo "Enter lower case text here"
read foo
var=`echo $foo | tr "{a-z}" "{A-Z}"`
# {a-z} Matches a through z
# {A-Z} matches A through Z
echo $var

but I'm not sure I fully understand ` ` I think it allows the output from an application to be stored in a variable. In this example the output from echo $foo | tr "{a-z}" "{A-Z}" is saved in var. So what does tr do? Change lower case to upper case. Why does it do that?

The tr utility copies the given input to produced the output with substitution or deletion of selected characters. tr abbreviated as translate or transliterate. It takes as parameters two sets of characters, and replaces occurrences of the characters in the first set with the corresponding elements from the other set i.e. it is used to translate characters.
QUOTE Thanks