- Joined
- Oct 30, 2010
- Messages
- 273
- Reaction score
- 0
- Points
- 16
- Location
- Southern Illinois
- Your Mac's Specs
- MBP 15" I7 first one and loving it.
#!/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.
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.